$('div').on('click', function (ev) {
if (ev.target.tagName === 'SPAN') {
if ($(ev.target).prev().is(':checked') === false) {
$(ev.target).prev().attr('checked', true)
}
else {
$(ev.target).prev().attr('checked', false)
}
}
});
so, when i click on my span element the radio from unchecked becomes checked and then when i click again it becomes unchecked as it should, but then it breaks, thats it... that's my problem. When i click on it more then 2 times in doesn't changes the checked value to anything. Here is my HTML
<div>
<input type="text" placeholder="Answer...">
<input type="radio" name="1"> <span>Answer 1</span>
<input type="radio" name="1"> <span>Answer 2</span>
<input type="radio" name="1"> <span>Answer 3</span>
<input type="radio" name="1"> <span>Answer 4</span>
</div>