标签:ids source type var javascrip enter sources cli style
<tr bgcolor="#FFFFFF"> <td width="18%" height="30" align="center">资源名称</td> <td width="82%" colspan="3"> <input type="checkbox" id="all">全选 <input type="checkbox" id="reverse">反选 </td> </tr> <tr bgcolor="#FFFFFF"> <td width="18%" height="30" align="center"> </td> <td width="82%" colspan="3"> <c:if test="${resources != null}"> <c:forEach items="${resources}" var="resource"> <c:forEach items="${role.resources}" var="r"> <c:if test="${r.uuid == resource.uuid}"> <input type="checkbox" name="resourceUuids" value="${resource.uuid}" checked>${resource.name} <c:set value="${r.uuid}" var="uid"/> </c:if> </c:forEach> <c:if test="${uid != resource.uuid}"> <input type="checkbox" name="resourceUuids" value="${resource.uuid}">${resource.name} </c:if> </c:forEach> </c:if> </td> </tr>
<script type="text/javascript"> $(function () { //全选 $("#all").click(function () { var flag = $(this).attr("checked"); $("[name=resourceUuids]").attr("checked",flag == "checked"); }); //反选 $("#reverse").click(function () { $("[name=resourceUuids]").each(function () { var flag = $(this).attr("checked"); $(this).attr("checked",!(flag == "checked")); }) var Flag = true; $("[name=resourceUuids]").each(function () { var flag = $(this).attr("checked") == "checked"; Flag = Flag && flag; }) $("#all").attr("checked",Flag); }); //绑定组件 $("[name=resourceUuids]").click(function () { var Flag = true; $("[name=resourceUuids]").each(function () { var flag = $(this).attr("checked") == "checked"; Flag = Flag && flag; }) $("#all").attr("checked",Flag); }); }); </script>
标签:ids source type var javascrip enter sources cli style
原文地址:http://www.cnblogs.com/xuweiweiailixing/p/6935082.html