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

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(',')存在一个数组里然后进行批量操作

努力学习,每天进步一点点。加油
原文地址:https://www.cnblogs.com/yalunwang/p/4847730.html