Jquery for Select All Checkbox

A very common interface is a list of items with a checkbox to select each and them you perform an action on those selected. Typically you have a checkbox at the top to toggle all of the list. This script will take care of everything for you. You can exclude elements by checking the ID or name properties.

$(document).ready(function() {
$("#selectAllCheckBox").click(function() {
var checked_status = this.checked;
$("input[type=CheckBox]").each(function() {
if (this.id != "pleaseSkipMe") {
this.checked = checked_status;


thorn said…
Using jQuery you don't need to write so mush code.

$(function() {
$("#selectAllCheckBox").click(function() {
$(':checkbox').not('#pleaseSkipMe').attr('checked', this.checked);
Paul G Brown said…
@Thorn -- Thanks. I'll get it updated soon.

Popular posts from this blog

Simple Age Calculation

Windows 8 Keyboard Shortcuts

VS Removes Usings and Can't Find Types