jQuery实现Table表格隔行变色及高亮显示当前选择行效果示例
本文实例讲述了jQuery实现Table表格隔行变色及高亮显示当前选择行效果。分享给大家供大家参考,具体如下:
最近客户要求高亮选择列表的功能,于是顺便做了个,作为记录。
前台代码:
<!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>JQuer的鼠标悬浮,鼠标高亮效果</title> <style type="text/css"> #header { background-color:#00ffff; text-align:center; } .style1 { text-align: right; } .style2 { text-align: center; } </style> <link href="tables.css" rel="external nofollow" rel="stylesheet" type="text/css" /> <script src="jquery-1.4.2.min.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function() { doChangeColorOfRow("#tableThis tr:even:not(#header)", "#tableThis tr:odd:not(#header)"); }); function doChangeColorOfRow(evenTR, oddTR) { $(evenTR).each(function() { $(this).css("background-color", "#F0F8FF").bind("mouseover", function() { if ($(this).css("background-color") != "#ffff00") { $(this).css("background-color", "#D8FAD8"); } }).bind("mouseout", function() { if ($(this).css("background-color") != "#ffff00") { $(this).css("background-color", "#F0F8FF"); } }).bind("click", function() { $(evenTR).each(function() { if ($(this).css("background-color") == "#ffff00") { $(this).css("background-color", "#F0F8FF"); } }); $(oddTR).each(function() { if ($(this).css("background-color") == "#ffff00") { $(this).css("background-color", "#ffffff"); } }); $(this).css("background-color", "#ffff00"); }); }); $(oddTR).each(function() { $(this).css("background-color", "#ffffff").bind("mouseover", function() { if ($(this).css("background-color") != "#ffff00") { $(this).css("background-color", "#D8FAD8"); } }).bind("mouseout", function() { if ($(this).css("background-color") != "#ffff00") { $(this).css("background-color", "#ffffff"); } }).bind("click", function() { $(evenTR).each(function() { if ($(this).css("background-color") == "#ffff00") { $(this).css("background-color", "#F0F8FF"); } }); $(oddTR).each(function() { if ($(this).css("background-color") == "#ffff00") { $(this).css("background-color", "#ffffff"); } }); $(this).css("background-color", "#ffff00"); }); }); } </script> </head> <body> <form id="form1" runat="server"> <table style="width: 100%;" cellpadding="0" cellspacing="0" id="tableThis"> <tr id="header"> <td>纳税人</td> <td> 增值税</td> <td> 消费税</td> <td> 营业税</td> <td>小规模纳税人</td> <td>增值税小规模纳税人</td> </tr> <tr> <td class="style2">张三</td> <td class="style1"> 123423432.12</td> <td class="style1"> 32445345.13</td> <td class="style1"> 345564.25</td> <td class="style1">567657567.78</td> <td class="style1">3454353453.90</td> </tr> <tr> <td class="style2">李四</td> <td class="style1"> 34435345.34</td> <td class="style1"> 456546</td> <td class="style1"> 675675</td> <td class="style1">678879789</td> <td class="style1">34534534.0</td> </tr> <tr> <td class="style2">王五</td> <td class="style1"> 23424</td> <td class="style1"> 6546</td> <td class="style1"> 67868</td> <td class="style1">980890</td> <td class="style1">45345</td> </tr> <tr> <td class="style2">刘六</td> <td class="style1"> 234234</td> <td class="style1"> 123123</td> <td class="style1"> 324234</td> <td class="style1">342423</td> <td class="style1">345345</td> </tr> <tr> <td class="style2">赵七</td> <td class="style1"> 345345</td> <td class="style1"> 546546</td> <td class="style1"> 567567</td> <td class="style1">67867867</td> <td class="style1">67867</td> </tr> <tr> <td class="style2">王八</td> <td class="style1"> 345354</td> <td class="style1"> 345345</td> <td class="style1"> 5654</td> <td class="style1">567658678</td> <td class="style1">879879789</td> </tr> <tr> <td class="style2">李九</td> <td class="style1"> 34535</td> <td class="style1"> 4534</td> <td class="style1"> 756765</td> <td class="style1">867867</td> <td class="style1">897987987</td> </tr> <tr> <td class="style2">周十</td> <td class="style1"> 456434534</td> <td class="style1"> 546456 </td> <td class="style1"> 5675756</td> <td class="style1">67867867</td> <td class="style1">8797987</td> </tr> </table> </form> </body> </html>
更多关于jQuery相关内容感兴趣的读者可查看本站专题:《jQuery表格(table)操作技巧汇总》、《jQuery切换特效与技巧总结》、《jQuery扩展技巧总结》、《jQuery常用插件及用法总结》、《jQuery常见经典特效汇总》及《jquery选择器用法总结》
希望本文所述对大家jQuery程序设计有所帮助。
- javascript实现table表格隔行变色的方法
- JavaScript获取表格(table)当前行的值、删除行、增加行
- JavaScript遍历table表格中的某行某列并打印其值
- 键盘上下键移动选择table表格行的js代码
- js操作table元素实现表格行列新增、删除技巧总结
- JS实现table表格内针对某列内容进行即时搜索筛选功能
- js处理表格对table进行修饰
- jQuery 选择表格(table)里的行和列及改变简单样式
- jQuery对table表格进行增删改查
- 基于JQuery的动态删除Table表格的行和列的代码
- jQuery+CSS实现的table表格行列转置功能示例
- JS/jQuery实现超简单的Table表格添加,删除行功能示例
相关文章
jQuery中图片展示插件highslide.js的简单dom
Highslide是一个非常美观的图片灯箱插件,下面这篇文章主要给大家介绍了关于jQuery中图片展示插件highslide.js的简单dom,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧。2018-04-04web的各种前端打印方法之jquery打印插件jqprint实现网页打印
本文介绍JQuery插件Jqprint实现网页打印,不懂的同学正可借此机会学习下,以备不时之需,话不多说,切入主题2013-01-01jquery ui dialog ie8出现滚动条的解决方法
jquery ui 的 dialog 在IE8下会出现不该出现的滚动条,在JQUI的FORUM上SEARCH下,发现也有人碰上,当解决办法就是把滚动条隐藏2010-12-12jQuery lazyLoad图片延迟加载插件的优化改造方法分享
jQuery lazyLoad.js插件 是一款基于jquery框架,可以“实现”图片延迟加载的插件2013-08-08
最新评论