I would like to uncheck all checkboxes that have a specific class with the exception of the one just checked.
function PizzaToppings_OptionValueChanged(checkboxElement) {
if ($(checkboxElement).attr("checked")) {
if($(checkboxElement).hasClass('cheese_toppings'))
{
// This will uncheck all other "cheese_toppings" but I want the newly selected item "checkboxElement" to remain checked.
$('input:checkbox.cheese_toppings').attr('checked', false);
}
}
}
The code above will uncheck all “cheese_toppings” including the one just selected. I don’t want to then recheck the one just selected or the event will be recalled.
I thought the best solution would be to remove “checkboxElement” from the list returned by $('input:checkbox.cheese_toppings') and then set the .attr('checked', false) to that list. But I’m not sure how to remove checkboxElement from the list.
See the jQuery docs: .not()