Benny Benny - 1 year ago 41
HTML Question

Check other checkboxes when check one box

I have a checkbox in my page. When I check it, other check boxes should be checked. And when I uncheck it, all the other check boxes should be unchecked too. How can I do this using jQuery? Or is simple HTML is enough?FIDDLE

<div>Select All<input type="checkbox" checked="true"></div>
1.<input type="checkbox">
2.<input type="checkbox">
3.<input type="checkbox">
4.<input type="checkbox">
5.<input type="checkbox">

Answer Source

Usig jQuery you can do like this


<input id='selectall' type="checkbox" checked="true">


$('#selectall').change(function () {
    if ($(this).prop('checked')) {
        $('input').prop('checked', true);
    } else {
        $('input').prop('checked', false);

Check this in fiddle

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download