I have a list item with a radio button input in each, on click of the list item the input is checked. However, if clicked again I want to remove the class and deselect the option. I can't seem to get anything to work however.
function setupToptions() {
if ($('ul.top-options input').length) {
$('ul.top-options li').each(function(){
$(this).removeClass('active');
});
$('ul.top-options li input:checked').each(function(){
$(this).parent('li').addClass('active');
});
};
};
What is wrong?
clickhandler here. And where do you 'deselect' your radio buttons in the above example? I believe you should useselectedand remove attributeselectedwhen working with radio buttons. You're now usingcheckedwhich only applies on checkboxes