html - jquery: check all/none checkbox only works once -
i making check all/none checkbox. however, works once: can check all, uncheck all, cannot check them again.
check all/none: <input type = "checkbox" id = "check_all_none"></input> <br/> <input type = "checkbox" class = "others"></input><br/> <input type = "checkbox" class = "others"></input> $('#check_all_none').change(function () { if ( $(this).is(':checked') ){ $('.others').attr("checked", true); } else{ $('.others').removeattr("checked"); // $('.others').attr("checked", false); // tried this, } });
try this
$('#check_all_none').click(function () { if ( $(this).is(':checked') ){ $('.others').prop("checked", true); } else{ $('.others').removeattr("checked"); } });
Comments
Post a Comment