本文介绍了复选框列表在回发后丢失复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我有复选框列表和复选框,将数据绑定到复选框后,如果我们选中所有复选框,则主复选框获取选择了它的罚款,但是当我们取消选中复选框列表中的任何复选框并单击按钮时,复选框列表中的所有复选框都将取消选中。 如何在回复后保留复选框列表中的选中项目。 Javascript代码 function pageLoad(sender,args){ CheckAllProject() ; } 功能CheckAllProject(){ $ ( [id * = lbxProjectList])。focus(function(){ if ($( [id * = lbxProjectList] input:选中)。length == $( [id * = lbxProjectList] input )。length){ $( [id * = CheckBox1])。attr ( 选中, 选中); } else { $( [id * = CheckBox1])。removeAttr( 选中); } }); } 看起来如下: 项目列表:CheckBox选择所有项目 复选框1项目1 复选框2项目2 按钮提交解决方案 ( [id * = lbxProjectList])。focus(function(){ if ( ( [id * = lbxProjectList] input:checked)。length == ( [id * = lbxProjectList] input)。length){ Hi,I have check box list and a check box, After binding the data to the checkbox, if we select the all checkboxes then the main checkbox gets selected its fine till now but when we unselect any check box in checkbox list and clicks a button then all checkboxes in the checkboxlist getting unchecked.How to Hold the checked items of the checkbox list even after the post back.Javascript codefunction pageLoad(sender, args) { CheckAllProject(); }function CheckAllProject () { $("[id*=lbxProjectList]").focus(function () { if ($("[id*=lbxProjectList] input:checked").length == $("[id*=lbxProjectList] input").length) { $("[id*=CheckBox1]").attr("checked", "checked"); } else { $("[id*=CheckBox1]").removeAttr("checked"); } }); }It Looks like in the following wayProject List:CheckBox Select All ProjectsCheckbox 1 Project1Checkbox 2 Project2Button Submit 解决方案 ("[id*=lbxProjectList]").focus(function () { if (("[id*=lbxProjectList] input:checked").length ==("[id*=lbxProjectList] input").length) { 这篇关于复选框列表在回发后丢失复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!