I want a group of check boxes on a page, when you select a check box I want to clear any other check boxes of checks and just check the one you just clicked on. I have a fiddle that I thought should work, but it never checks the one you clicked on. I don't want to use radio buttons as "no selection" is valid as well
$("#mytable input").change(function(){
$("#mytable input").attr('checked',false);
$(this).attr('checked',true);
})
You should rather use radio button with same name. using checkboxes, you need to use:
$("#mytable input").change(function() {
$("#mytable input").not(this).prop('checked', false);
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.