注:funs是从action中传过来的list<Function> 其中属性中有其子对象list<role> 下面通过s标签遍历 ,也可以通过c标签遍历

jsp页面中:

<s:iterator value="funs" var="fun">
         <tr>
           <td><!-- 父权限的列表 -->
             <input type="checkbox" name="checkFuns" />${childFun.fname}           
             </s:iterator>
           </td>
         </tr>
       </s:iterator>

 

jquery中写法:

$(function(){
 //选中父权限,子权限都要选中
 $("input[id^='parent_']").click(function(){//红色^代表从parent_开始
  var id = $(this).val();
  $("input[id^='child_"+id+"_']").prop('checked',$(this).prop('checked'));
 });
 
 //如果子权限选中的个数,跟子权限的个数一样的话,父权限也要选中
});

 

相关文章:

  • 2022-12-23
  • 2021-07-08
  • 2021-11-27
  • 2021-08-08
  • 2022-01-09
  • 2021-11-04
  • 2021-12-07
猜你喜欢
  • 2021-06-05
  • 2022-12-23
  • 2021-10-26
  • 2021-12-18
  • 2021-05-24
  • 2021-06-25
相关资源
相似解决方案