<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>jquery表格修饰:隔行换色,点击变色,多选单选变色</title> </head> <script language=javascript src="http://code.jquery.com/jquery-1.4.2.min.js"></script> <style> </style> <SCRIPT LANGUAGE="JavaScript"> <!-- /* jQuery实现点击复选框即高亮显示选中行 全选、反选 详见http://www.cnblogs.com/chengulv/archive/2012/02/25/2368055.html */ (function ($) { $.fn.extend({ "alterBgColor": function (options) { var prevselitem = null; //设置默认值 options = $.extend({ // style: "0", odd: "odd", /* 偶数行样式*/ even: "even", /* 奇数行样式*/ over: "over", /* 鼠标掠过*/ selected: "selected" /* 选中行样式*/ }, options); //样式4 //其他列 为单选 $('tbody>tr td:not(:first-child)', this).click(function () { var p = $(this).parents("tr"); p.addClass(options.selected).siblings().removeClass(options.selected).find(':checkbox:first').attr('checked', false); p.find(':checkbox:first').attr('checked', true); }); } }); })(jQuery); $(document).ready(function () { $(':checkbox[name=tablechoice]').each(function(){ $(this).click(function(){ if($(this).attr('checked')){ $(':checkbox[name=tablechoice]').removeAttr('checked'); $(this).attr('checked','checked'); } }); }); $("#listTable").alterBgColor(); //可以链式操作 }); //--> </SCRIPT> </head> <body> <h1>Demo2--隔行,滑动,点击 变色.+ 多选框选中的行 变色.</h1> <table class="dataTable" id='listTable'> <thead> <tr> <th></th> <th>姓名</th> <th>性别</th> <th>暂住地</th> </tr> </thead> <tbody> <tr> <td><input type="checkbox" name="tablechoice" value="" /></td> <td>张山</td> <td>男</td> <td>浙江宁波</td> </tr> <tr> <td><input type="checkbox" name="tablechoice" value="" /></td> <td>李四</td> <td>女</td> <td>浙江杭州</td> </tr> <tr> <td><input type="checkbox" name="tablechoice" value="" checked/></td> <td>王五</td> <td>男</td> <td>湖南长沙</td> </tr> <tr> <td><input type="checkbox" name="tablechoice" value="" /></td> <td>找六</td> <td>男</td> <td>浙江温州</td> </tr> <tr> <td><input type="checkbox" name="tablechoice" value="" /></td> <td>Rain</td> <td>男</td> <td>浙江杭州</td> </tr> <tr> <td><input type="checkbox" name="tablechoice" value="" /></td> <td>MAXMAN</td> <td>女</td> <td>浙江杭州</td> </tr> </tbody> </table> </body> </html>
详细解决方案
jQuery报表单选
热度:331 发布时间:2013-12-02 12:00:40.0
相关解决方案
- jquery 获取jsp页面的id解决方法
- jquery,二维数组取值。解决办法
- 求jquery.form.js+jquery.validate.min.js 用ajax提交表单的代码范例
- jquery 提交form表单不用插件的那种 如何提交
- jquery ajax回传没有值,该怎么处理
- jquery easyUI datagrid struts2有关问题
- jquery form 有关问题
- springmvc jquery ajax 提交复杂对象,415异常解决办法
- 应用Struts2 与 jquery,ajax验证用户注册,不用从数据库获取数据
- jquery ajax select解决方法
- php jquery check username ajax检察帐号唯一性
- jquery ajax返回值的有关问题
- jquery 或js 获取指定字符间的字符串,并轮换。回答出来的是大神级~
- jquery 的bind里面能不能获得返回值呢? 对小弟我很难的有关问题啊
- jquery 的uploadify下传图片怎么让出错信息提示成中文
- java+jquery easy ui + json + struts分页例子
- jquery easyui分页效率有关问题
- jquery 如何获得动态添加后的子元素个数?
- jQuery.ajax()请求struts2数据 回到data值了undefined
- 关于Struts2 jQuery Plugin的 Result,该如何处理
- Jquery 点击按钮实现图片翻页,该如何解决
- jquery 关于监听checkbox的选中和不选中事件,该如何解决
- jQuery append动态添加的页面对象如何处理刷新掉
- Jquery+json解决思路
- jquery post有关问题
- 求大神解决偏题 - jquery ajax
- jquery $.ajax有关问题
- jquery td遍历有关问题
- jquery ui taps有关问题,求解!
- jquery easyui 如何设置标题列居左,里面的数据列居右