首页 > Web开发 > 详细

js 获取checkbox选中项目

时间:2016-01-10 15:32:15      阅读:216      评论:0      收藏:0      [点我收藏+]

#

//获取选中项
$(‘#submit‘).click(function () {
    var check_list = []
    $("input[name=‘ck‘]:checked").each(function () {
        check_list.push(this.value);
    });
    alert(check_list.join(","));
});

//全选/取消全选
$(‘#all‘).toggle(function () {
    $("input[name=‘ck‘]").attr("checked", ‘true‘);
}, function () {
    $("input[name=‘ck‘]").removeAttr("checked");
});


//反选
$(‘#unselected‘).click(function () {
    $("input[name=‘ck‘]").each(function () {
        if ($(this).attr("checked")) {
            $(this).removeAttr("checked");
        } else {
            $(this).attr("checked", ‘true‘);
        }
    });
});

#

js 获取checkbox选中项目

原文:http://www.cnblogs.com/weiok/p/5118482.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!