zoukankan      html  css  js  c++  java
  • 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="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>

  • 相关阅读:
    Hibernate一 入门
    angularJS测试一 Karma Jasmine Mock
    angularJS constant和value
    AngularJS $on $broadcast $emit
    css读书笔记4:字体和文本
    css读书笔记3:定位元素
    css读书笔记2:css工作原理
    css读书笔记1:HTML标记和文档结构
    html5中插入视频和音频
    html5中的表单
  • 原文地址:https://www.cnblogs.com/Resources-blogs/p/6604125.html
Copyright © 2011-2022 走看看