js实现复选框(单选,全选)
<head>
<body>
<div class="img-list w760 bor-top margin-t10 line-h35" id="container">
<ul class="bgColor w760 align-c">
<li class="w48">
<input type="checkbox" name="checkall" id="checkall" /></li>
<li class="w48"></li>
<li class="w120"><b>昵称</b></li>
<li class="w170"><b>性别</b></li>
<li class="w170 align-c"><b>最后发言</b></li>
<li class="w100"></li>
</ul>
<asp:Repeater ID="Rpcirclemember" runat="server">
<AlternatingItemTemplate>
<ul class="w760 align-c bgColor">
<li class="w48 margin-t10" item="">
<input type="checkbox" name="circlecheck" value="<%#Eval("UserId")%>" realname="<%#Eval("UserName")%>" /></li>
<li class="w48">
<img src="<%#Eval("HeadUrl")==null ? "/images/default-img/default-user.jpg" : Eval("HeadUrl") %>"
alt="成员头像" class="img-bor" /></li>
<li class="w120 margin-t10 colorBlue">
<%#string.IsNullOrEmpty(Eval("UserName").ToString()) ? "匿名" :Eval("UserName")%></li>
<li class="w170 margin-t10">
<%#string.IsNullOrEmpty(GetSex(Eval("Sex").ToString()))? "未填写" : GetSex((Eval("Sex").ToString()))%></li>
<li class="w170 align-c margin-t10">
<%#Eval("LastSpeakDate")%></li>
<li class="w100 colorRed margin-t10">
<%#(bool)Eval("IsSilence") == true ? "<em class='icon-ban' title='禁言'></em>" : ""%>
</li>
</ul>
</AlternatingItemTemplate>
<ItemTemplate>
<ul class="w760 align-c">
<li class="w48 margin-t10" item="">
<input type="checkbox" name="circlecheck" value="<%#Eval("UserId")%>" realname="<%#Eval("UserName")%>" /></li>
<li class="w48">
<img src="<%#Eval("HeadUrl")==null ? "/images/default-img/default-doctor.jpg" : Eval("HeadUrl") %>"
alt="成员头像" class="img-bor" /></li>
<li class="w120 margin-t10 colorBlue">
<%#string.IsNullOrEmpty(Eval("UserName").ToString()) ? "匿名" : Eval("UserName")%></li>
<li class="w170 margin-t10">
<%#string.IsNullOrEmpty(GetSex(Eval("Sex").ToString()))? "未填写" : GetSex(Eval("Sex").ToString())%></li>
<li class="w170 align-c margin-t10">
<%#Eval("LastSpeakDate")%></li>
<li class="w100 colorRed margin-t10">
<%#(bool)Eval("IsSilence")==true ? "<em class='icon-ban' title='禁言'></em>" : ""%>
</li>
</ul>
</ItemTemplate>
</asp:Repeater>
</div>
</body>
</head>
$("#checkall").click(function(){
var flag=$("#checkall").attr("checked");
if(flag){
$("input[name=circlecheck]").each(function(){
$(this).attr("checked",flag);
});
else {
$("input[name=circlecheck]").each(function(){
$(this).attr("checked",false);
});
}
}
});
$("input[name=circlecheck]").each(function(){
$(this).click(fucntion(){
if($("input[name=circlecheck] :checked").length==$("input[name=circlecheck]").length){
$("#checkall").attr("checked",true);
}
else{
$("#checkall").removeAttr("checked");
}
});
});