07-03-2010

Javascript toggle all checkboxes checked or unchecked

This jquery code loops through all checkboxes in the dom and sets their checked attribute to the opposite of what it currently is.

$('input[type=checkbox]').each(function(){
	$(this).attr("checked",!$(this).attr("checked"));
}) 
 

Comments:

Your comment:

»
Peter Ots, Flower Mound, TX, USA 15/05/2010, 11:07 pm
Thank you, this is exactly what I was looking for. Other scripts (including my earlier one) are not as simple or they require a plugin.

 

[x]