Jquery Check All

Here we can do with jquery, check all checkbox with name parameters :

sample code :

function checkallitems(){

var arr=$(“input[name=’contest[]’][type=’checkbox’]”);
if($(‘#contestall’).attr(‘checked’)==true){
for(var i=0;i<arr.length;i++){
$(arr[i]).attr(‘checked’,’checked’);
}
}else{
for(var i=0;i<arr.length;i++){
$(arr[i]).attr(‘checked’,false);
}
}

}

note :

contest[] is the name of checkbox will be checked.

contestall is a checkbox  for control  check and uncheck.

regards,



LEAVE A REPLY