check uncheck All checkboxes with another single checkbox use jquery

后端 未结 10 551
长情又很酷
长情又很酷 2020-12-03 05:14

I use jquery-1.9.1.js In my html page, it works well for the first time.

just like http://jsfiddle.net/pzCcE/1/

Can somebody help me to improve it?

10条回答
  •  旧时难觅i
    2020-12-03 05:58

    I've just simplified @j08691 answer

    $("#checkAll").click(function() {
          var allChecked = $(this);
          $("#tab1 input[type=checkbox]").each(function() {
            $(this).prop("checked", allChecked.is(':checked'));
          })
        });
    
    
    Select all book1 book2 book3

提交回复
热议问题