Jquery单击选择权限实例

来源:互联网 发布:android 全景拼接算法 编辑:程序博客网 时间:2024/05/23 00:04

HTML代码:

            <table class="table table-bordered table-striped with-check">              <thead>                <tr>                  <th></th>                  <th >一级权限</th>                  <th ></th>                </tr>              </thead>              <tbody>               <tr >                <td style="text-align:center"></td>                 <td style="text-align:center"><label><input type="checkbox" class="authcheck"></label></td><td ><input type="checkbox" class="authcheck1">{$vv.auth_name}</td>              </tr>              </tbody>            </table>

jQuery代码:

       $('.authcheck').click(function(){            if ($(this).is(":checked")) {                $(this).parent().parent().next().children('input').attr("checked",true)            }else{                $(this).parent().parent().next().children('input').attr("checked", false)            }        })        var i=0;        $('.authcheck1').click(function(){           //alert( $(this).parent().children('input').css('background','red'));           $(this).parent().children('input').each(function (index, domEle) {            if($(this).attr("checked")!='checked'){                i=1;            }           });            if(i==0){            $(this).parent().prev().children().children('input').attr("checked", true)            }else{            $(this).parent().prev().children().children('input').attr("checked", false)            }            i=0;        })


0 0