lundi 28 décembre 2015

check/uncheck checkboxes upon checking a checkbox

hi all i am trying to check a check box which upon checking will check remaining checkboxes present in the form using classes how can i do it??

enter code here
<!DOCTYPE html>
<html>
<head>

<script>
$(".global").on("click", function() {
var all = $(this);
$('.checkbtn').each(function() { 
$(this).prop("checked", all.prop("checked"));
});
});
</script>
</head>
<body>
<div>
     <input type="checkbox" class ="global" id="select-all" name="selectAll" value=""/> All
<input type="checkbox" class ="checkbtn" name="practice" value=""/> 1
<input type="checkbox" class ="checkbtn" name="filename" value=""/> 2
<input type="checkbox" class ="checkbtn" name="comment" value=""/> 3

 </div>
 </body>
 </html>




Aucun commentaire:

Enregistrer un commentaire