Tuesday, July 20, 2010

Select ALL - jQuery

I am so happy that i can achieve things in 1 line of code using jQuery.
To Select all the checkboxes in the grid..
$(":checkbox").each(function() { this.checked = document.getElementById('chkAll').checked; });

To findout atleast one checbox should be selected
var isChecked = false;
$(":checkbox").each(function() { if (this.checked == true) isChecked = true; });

or
if ($(":checkbox:checked").length > 0) {
isChecked = true;

}

No comments:

Post a Comment