码迷,mamicode.com
首页 > Web开发 > 详细

jquery获取当前被选择的复选框的value的集合

时间:2015-09-30 06:17:39      阅读:184      评论:0      收藏:0      [点我收藏+]

标签:

1.HTML代码

<input type="checkbox" name="productID" value="0">
<input type="checkbox" name="productID" value="1">
<input type="checkbox" name="productID" value="2">
<input type="checkbox" name="productID" value="3">
<input type="checkbox" name="productID" value="4">
<input type="checkbox" name="productID" value="5">

2.jquery

        var ProductIDs = "";
        $(‘input[name="productID"]:checked‘).each(function() {
            if ( ProductIDs == "")
                 ProductIDs = $(this).val();
            else
                ProductIDs = ProIDs + "," + $(this).val();
        });
       

  3、这样ajax批量操作(例如,删除),后台可以通过spilt(‘,‘)存在一个数组里然后进行批量操作

jquery获取当前被选择的复选框的value的集合

标签:

原文地址:http://www.cnblogs.com/yalunwang/p/4847730.html

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