JQuery 进入页面默认给已赋值的复选框打钩
效果:
JQuery代码:
$("#menuTree").find("div span").click(function () { currmenuid = this.id; var currmenuname = LoadCurrMenuName(); $('#authName').text(currmenuname); //默认给已赋值的菜单打钩 var rightvalue= AutoCheck(); var str = ""; var strArr = []; for (var i = 0; i < rightvalue.length; i++) { str = rightvalue[i]; strArr.push(str); } var input = $('.che'); for (var n = 0; n < strArr.length; n++) { if (strArr[n] == 1) { input[n].checked = true; } else { input[n].checked = false; } } })
HTML代码:
<div style="width:100%; margin:auto"> <fieldset class="duxuan"> <legend id="authName" style="font-size:12px;">权限管理</legend> <div class="duleft"> <ul> <li> <input class="che" type="checkbox" name="CheckboxGroup1" value="0" id="CheckboxGroup1_1" />有效 </li> <li> <input class="che" type="checkbox" name="CheckboxGroup1" value="0" id="CheckboxGroup1_2" />银码 </li> <li> <input class="che" type="checkbox" name="CheckboxGroup1" value="0" id="CheckboxGroup1_3" />查询 </li> <li> <input class="che" type="checkbox" name="CheckboxGroup1" value="0" id="CheckboxGroup1_4" />新增 </li> <li> <input class="che" type="checkbox" name="CheckboxGroup1" value="0" id="CheckboxGroup1_5" />修改 </li> <li> <input class="che" type="checkbox" name="CheckboxGroup1" value="0" id="CheckboxGroup1_6" />删除 </li> <li> <input class="che" type="checkbox" name="CheckboxGroup1" value="0" id="CheckboxGroup1_7" />提交 </li> <li> <input class="che" type="checkbox" name="CheckboxGroup1" value="0" id="CheckboxGroup1_8" />统计 </li> <li> <input class="che" type="checkbox" name="CheckboxGroup1" value="0" id="CheckboxGroup1_9" />复核 </li> <li> <input class="che" type="checkbox" name="CheckboxGroup1" value="0" id="CheckboxGroup1_10" />签收 </li> <li> <input class="che" type="checkbox" name="CheckboxGroup1" value="0" id="CheckboxGroup1_11" />返回 </li> <li> <input class="che" type="checkbox" name="CheckboxGroup1" value="0" id="CheckboxGroup1_12" />导出 </li> <li> <input class="che" type="checkbox" name="CheckboxGroup1" value="0" id="CheckboxGroup1_13" />打印 </li> <li> <input class="che" type="checkbox" name="CheckboxGroup1" value="0" id="CheckboxGroup1_14" />查看 </li> <li> <input class="che" type="checkbox" name="CheckboxGroup1" value="0" id="CheckboxGroup1_15" />隶属角色 </li> <li> <input class="che" type="checkbox" name="CheckboxGroup1" value="0" id="CheckboxGroup1_16" />隶属用户 </li> </ul> </div> <div class="duright"> <div class="rleft"> <div class="rlup" id="selectAll" role="button">全选</div> <div class="rldown" id="resetAll" role="button">清空</div> </div> <div class="rright" id="saveAll"> 保存权限 </div> </div> </fieldset> </div>
相关推荐
开心就好 2020-06-10
EdwardSiCong 2020-11-23
85477104 2020-11-17
hhanbj 2020-11-17
81427005 2020-11-11
seoppt 2020-09-13
honeyth 2020-09-13
WRITEFORSHARE 2020-09-13
84483065 2020-09-11
momode 2020-09-11
85477104 2020-08-15
83510998 2020-08-08
82550495 2020-08-03
tthappyer 2020-08-03
84901334 2020-07-28
tthappyer 2020-07-25
TONIYH 2020-07-22
tztzyzyz 2020-07-20
83510998 2020-07-18