Home  >  Article  >  Backend Development  >  关于一些简单的jquery有关问题

关于一些简单的jquery有关问题

WBOY
WBOYOriginal
2016-06-13 12:10:02825browse

关于一些简单的jquery问题

<br /><tr><br /> <td width="2%"> </td><br />       <td><br />           input type="checkbox" name="role_auth_ids[]" class="menus" value="1"/><b><font color='red'>权限管理</b></font></td><br />        <td><br />             <div style="width:100px;float:left" id="d1"><input type="checkbox" name="role_auth_ids[]" class="submenus" value="2"/>添加权限</div><br />            <div style="width:100px;float:left" id="d1"><input type="checkbox" name="role_auth_ids[]" class="submenus" value="3"/>权限列表</div><br />            <div style="width:100px;float:left" id="d1"><input type="checkbox" name="role_auth_ids[]" class="submenus" value="7"/>权限分配</div><br />         </td><br /></tr>


我想问的是使用jquery怎么实现 在选中权限管理得情况下,取消选中 '添加权限' 和 '权限列表' 和 '权限分配' 时,权限管理也自动取消选中。 也就是取消选中最后面单元格的checkbox就自动取消选中 权限管理
------解决思路----------------------
$(function() {<br />  $('[name="role_auth_ids[]"]:eq(0)').click(function() {<br />    if($(this).prop('checked') == false) $('[name="role_auth_ids[]"]:gt(0)').prop('checked', false);<br />  });<br />  $('[name="role_auth_ids[]"]:gt(0)').click(function() {<br />    var n = 0;<br />    $('[name="role_auth_ids[]"]:gt(0)').each(function() {<br />      if($(this).prop('checked')) n++;<br />    });<br />    $('[name="role_auth_ids[]"]:eq(0)').prop('checked', n ? true : false);<br />  });<br />})<br />

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