码迷,mamicode.com
首页 > Web开发 > 详细

Jquery选中行实现行中的Checkbox的选中与取消选中

时间:2015-05-26 18:24:38      阅读:171      评论:0      收藏:0      [点我收藏+]

标签:

以下是代码,我是用的aspx页面写的,可以修改成HTML页面,鄙人亲身测试过了的,能行哈,兼容IE8,火狐浏览器,IE其他浏览器就没有测试了哦。
<%Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server">     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />     <title></title>     <script src="js/jquery.js"></script>     <script type="text/javascript">         $(function () {             $("#info").find("tr").click(function () {                 var checkbox = $(this).find("input[type=checkbox]");                 if (checkbox.is(":checked")) {                     checkbox.prop("checked", false);                     $(this).css("background-color", "");                 } else {                     checkbox.prop("checked", true);                     $(this).css("background-color", "pink");                 }             })         })     </script>     <style type="text/css">         table {             border-collapse: collapse;         }             table tr td {                 border: 1px solid red;             }     </style> </head> <body>     <form id="form1" runat="server">         <div>             <table id="info">                 <tr>                     <td style="width40px;">选择</td>                     <td>用户名</td>                     <td>密码</td>                     <td>备注</td>                 </tr>                 <tr>                     <td>                         <asp:CheckBox ID="CheckBox1" runat="server" /></td>                     <td>张三</td>                     <td>123</td>                     <td>喝完了酒两位咯危机or叫我阿胶尾盘快速扩散的扑克牌上看到佛山恐怕文凭</td>                 </tr>                 <tr>                     <td>                         <asp:CheckBox ID="CheckBox2" runat="server" /></td>                     <td>张三</td>                     <td>123</td>                     <td>喝完了酒两位咯危机or叫我阿胶尾盘快速扩散的扑克牌上看到佛山恐怕文凭</td>                     <tr>                         <td>                             <asp:CheckBox ID="CheckBox3" runat="server" /></td>                         <td>张三</td>                         <td>123</td>                         <td>喝完了酒两位咯危机or叫我阿胶尾盘快速扩散的扑克牌上看到佛山恐怕文凭</td>                     </tr>                     <tr>                         <td>                             <asp:CheckBox ID="CheckBox4" runat="server" /></td>                         <td>张三</td>                         <td>123</td>                         <td>喝完了酒两位咯危机or叫我阿胶尾盘快速扩散的扑克牌上看到佛山恐怕文凭</td>                     </tr>                     <tr>                         <td>                             <asp:CheckBox ID="CheckBox5" runat="server" /></td>                         <td>张三</td>                         <td>123</td>                         <td>喝完了酒两位咯危机or叫我阿胶尾盘快速扩散的扑克牌上看到佛山恐怕文凭</td>                     </tr>                 </tr>             </table>         </div>     </form> </body> </html>

Jquery选中行实现行中的Checkbox的选中与取消选中

标签:

原文地址:http://www.cnblogs.com/LoveQin/p/4530995.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!