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.

http://jsfiddle.net/sdewb/

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");  }  }); 

demo


Comments

Popular posts from this blog

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

javascript - addthis share facebook and google+ url -