码迷,mamicode.com
首页 > 其他好文 > 详细

Toggle Checkboxes on/off

时间:2017-06-18 15:49:32      阅读:126      评论:0      收藏:0      [点我收藏+]

标签:http   flow   checkbox   when   man   com   member   off   boolean   

You can write:

$(document).ready(function() {
    $("#select-all-teammembers").click(function() {
        var checkBoxes = $("input[name=recipients\\[\\]]");
        checkBoxes.prop("checked", !checkBoxes.prop("checked"));
    });                 
});

Before jQuery 1.6, when we only had attr() and not prop(), we used to write:

checkBoxes.attr("checked", !checkBoxes.attr("checked"));

But prop() has better semantics than attr() when applied to "boolean" HTML attributes, so it is usually preferred in this situation.

 

 

ref: https://stackoverflow.com/questions/4177159/toggle-checkboxes-on-off

Toggle Checkboxes on/off

标签:http   flow   checkbox   when   man   com   member   off   boolean   

原文地址:http://www.cnblogs.com/pinganzi/p/7044308.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!