jquery代码
1 $(function () { 2 $('#inputCheck').click(function () { 3 if ($(this).attr("checked")) {//全选 4 $("input[name='chkSelect']").attr("checked", $(this).attr("checked")); 5 $("#selectAll").text("取消全选"); 6 } else { 7 $('table input[type=checkbox]').attr('checked', false); 8 $("#selectAll").text("全选"); 9 } 10 }); 11 });
页面代码
1 <table class="datalist"> 2 <tbody> 3 <asp:MvcRepeater ID="re1" runat="server" DataKey="list" EvenCss="even" OddCss="odd" 4 OrderByKey="order"> 5 <HeaderTemplate> 6 <thead> 7 <tr> 8 <th> 9 <input id="inputCheck" type="checkbox" /><span id="selectAll">全选</span> 10 11 </th> 12 <th> 13 <span>文章ID</span> 14 </th> 15 <th> 16 <span>文章名称</span> 17 </th> 18 <th> 19 <span>作者</span> 20 </th> 21 <th> 22 <span>创建时间 </span> 23 </th> 24 <th> 25 <span>分类</span> 26 </th> 27 <th> 28 <span>状态</span> 29 </th> 30 <%if (!string.IsNullOrEmpty(Request.QueryString["Stick_Home_Concern"])) 31 { %> 32 <th> 33 <span>标签</span> 34 </th> 35 <%} %> 36 <th> 37 <span>操作</span> 38 </th> 39 </tr> 40 </thead> 41 <tbody> 42 </HeaderTemplate> 43 <ItemTemplate> 44 <tr class="<%# MvcBind.AlterCss(Container) %>"> 45 <td class="tacenter"> 46 <input name="chkSelect" type="checkbox" value='<%#Eval("ArticleID") %>' /> 47 </td> 48 <td class="tacenter"> 49 <%# Eval("ArticleID")%> 50 </td> 51 <td class="tacenter"> 52 <a href='<%# Eval("url") %>/Home/NewsContent?id=<%# Eval("ArticleID")%>' target="_bank"> 53 <%# Eval("ArticleTitle")%></a> 54 </td> 55 <td class="tacenter"> 56 <%# Eval("Author")%> 57 </td> 58 <td class="tacenter"> 59 <%# Eval("InsertTime")%> 60 </td> 61 <td class="tacenter"> 62 <%# Eval("ClassName")%> 63 </td> 64 <td class="tacenter"> 65 <%# Eval("ApproveStatus")%> 66 </td> 67 <%if (!string.IsNullOrEmpty(Request.QueryString["Stick_Home_Concern"])) 68 { %> 69 <td class="tacenter"> 70 <%# Eval("Stick_Home_Concern")%> 71 </td> 72 <%} %> 73 <td class="tacenter"> 74 <a class="contextMenuBtn" uid="<%# Eval("ArticleID") %>" href="#">操作</a> 75 <ul id="contextMenu_<%# Eval("ArticleID") %>" class="contextMenu"> 76 <li class="cog"><a href="/Article/ArticleCreate?id=<%# Eval("ArticleID")%>&action=modify"> 77 编辑</a></li> 78 <%--<asp:MvcRepeaterInnerHolder ID="pla_1" runat="server" StatusField="ArticleStatus" StatusShowValue="1"> 79 <li class="cog"><a href="javascript:rejectArticle('<%# Eval("ArticleID") %>')">禁用</a></li> 80 </asp:MvcRepeaterInnerHolder>--%> 81 <%-- <asp:MvcRepeaterInnerHolder ID="pla_2" runat="server" StatusField="AddPic" StatusShowValue="2">--%> 82 <li class="cog"><a href="/Article/AddPic?id=<%# Eval("ArticleID")%>">图片管理</a></li> 83 <%-- </asp:MvcRepeaterInnerHolder>--%> 84 <li class="cog"><a href="javascript:deleteArticle('<%# Eval("ArticleID") %>')">删除</a> 85 </li> 86 </ul> 87 </td> 88 </tr> 89 90 </ItemTemplate> 91 </asp:MvcRepeater> 92 <tr> 93 <td><input id="BtnDelArticle" type="button" value="批量删除" /> 94 <input id="BtnUpdate" type="button" value="批量审核" /></td> 95 </tr> 96 </tbody> 97 </table>
判断一组复选框一个都没有选中的话
$("input[type='checkbox']").is(':checked')