注: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'));
});
//如果子权限选中的个数,跟子权限的个数一样的话,父权限也要选中
});