我已经制作了如下表格。
Sl No. Document title Description Revision Parts name Issue Link <tr id=""> <input type="checkbox" name="chkItem" class="chk" id="chkbox_" /> <a href='https://stackoverflow.com/questions/4813610/jquery-checkbox-manipulation-within-a-foreach-loop/'> Add
我需要实现以下目标:
首先,你可以这样做……
if($('.chk').is(':checked')){ //perform the action in controller }
第二点 –
$(".selectAll").click(function(){ var checked = $("#selectall").attr("checked"); $(".chk").attr("checked",checked); }
第三点 –
$(".chk").click(function(){ var checkedBoxes= $(".selectone").map(function(){ return jQuery(this).attr("checked");}).get(); var flg = true; if(jQuery.inArray(false, net)){ flg= false; } $("#selectall").attr("checked",flg); });
$("#selectall").click(function(){ var checked = $("#selectall").attr("checked"); $(".selectone").attr("checked",checked); });
用于设置全选
$(".selectone").click(function(){ var net = $(".selectone").map(function(){ return jQuery(this).attr("checked");}).get(); var flg = true; if(jQuery.inArray(false, net)){ flg= false; } $("#selectall").attr("checked",flg); });
Sl No. Document title Description Revision Parts name Issue Link test Test Add test Test Add test Test Add
以上就是jQuery教程分享foreach循环中的JQuery复选框操作相关内容,想了解更多jQuery开发(异常处理)及jQuery教程关注计算机技术网(www.ctvol.com)!)。
本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。
ctvol管理联系方式QQ:251552304
本文章地址:https://www.ctvol.com/jquerytutorial/557850.html