Home  >  Article  >  php教程  >  TP3.1.3视频教程-权限配置的JQ代码改进

TP3.1.3视频教程-权限配置的JQ代码改进

WBOY
WBOYOriginal
2016-06-07 11:44:34896browse

在ThinkPHP3.1.3视频教程的RBAC权限配置一节使用的JQ代码比较简单,选择方法后不会选定父级节点,使用上有些不太顺手,现在原代码的基础上稍加改动,实现了点选方法时,同时选中父节点。。。
<script></script><br> <script><br /> $(function(){<br /> <br /> $('input[level=1]').click(function(){ <br /> var inputs = $(this).parents('.app').find('input');<br /> $(this).attr('checked') ? inputs.attr('checked','checked') : inputs.removeAttr('checked'); <br /> }); <br /> <br /> $('input[level=2]').click(function(){<br /> var inputs = $(this).parents('.appAction').find('input');<br /> var inputp = $(this).parents('.app').find('input[level=1]');<br /> if($(this).attr('checked')){<br /> inputs.attr('checked','checked');<br /> inputp.attr('checked','checked');<br /> }else{<br /> inputs.removeAttr('checked'); <br /> } <br /> });<br /> <br /> $('input[level=3]').click(function(){<br /> var inputs = $(this).parents('.appAction').find('input[level=2]');<br /> var inputp = $(this).parents('.app').find('input[level=1]');<br /> if($(this).attr('checked')){<br /> inputs.attr('checked','checked');<br /> inputp.attr('checked','checked');<br /> }<br /> });<br /> });<br /> </script>

AD:真正免费,域名+虚机+企业邮箱=0元

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn