jQuery實(shí)現(xiàn)Table表格隔行變色及高亮顯示當(dāng)前選擇行效果示例
本文實(shí)例講述了jQuery實(shí)現(xiàn)Table表格隔行變色及高亮顯示當(dāng)前選擇行效果。分享給大家供大家參考,具體如下:
最近客戶要求高亮選擇列表的功能,于是順便做了個(gè),作為記錄。
前臺(tái)代碼:
<!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的鼠標(biāo)懸浮,鼠標(biāo)高亮效果</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> 消費(fèi)稅</td> <td> 營業(yè)稅</td> <td>小規(guī)模納稅人</td> <td>增值稅小規(guī)模納稅人</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>
更多關(guān)于jQuery相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《jQuery表格(table)操作技巧匯總》、《jQuery切換特效與技巧總結(jié)》、《jQuery擴(kuò)展技巧總結(jié)》、《jQuery常用插件及用法總結(jié)》、《jQuery常見經(jīng)典特效匯總》及《jquery選擇器用法總結(jié)》
希望本文所述對(duì)大家jQuery程序設(shè)計(jì)有所幫助。
- javascript實(shí)現(xiàn)table表格隔行變色的方法
- JavaScript獲取表格(table)當(dāng)前行的值、刪除行、增加行
- JavaScript遍歷table表格中的某行某列并打印其值
- 鍵盤上下鍵移動(dòng)選擇table表格行的js代碼
- js操作table元素實(shí)現(xiàn)表格行列新增、刪除技巧總結(jié)
- JS實(shí)現(xiàn)table表格內(nèi)針對(duì)某列內(nèi)容進(jìn)行即時(shí)搜索篩選功能
- js處理表格對(duì)table進(jìn)行修飾
- jQuery 選擇表格(table)里的行和列及改變簡(jiǎn)單樣式
- jQuery對(duì)table表格進(jìn)行增刪改查
- 基于JQuery的動(dòng)態(tài)刪除Table表格的行和列的代碼
- jQuery+CSS實(shí)現(xiàn)的table表格行列轉(zhuǎn)置功能示例
- JS/jQuery實(shí)現(xiàn)超簡(jiǎn)單的Table表格添加,刪除行功能示例
相關(guān)文章
從零開始學(xué)習(xí)jQuery (三) 管理jQuery包裝集
在使用jQuery選擇器獲取到j(luò)Query包裝集后, 我們需要對(duì)其進(jìn)行操作. 本章首先講解如何動(dòng)態(tài)的創(chuàng)建元素, 接著學(xué)習(xí)如何管理jQuery包裝集, 比如添加,刪除,切片等.2011-02-02jQuery實(shí)現(xiàn)的類flash菜單效果代碼
這里要說的就是一個(gè)菜單的hover的效果,一般我們通過CSS的偽類:hover實(shí)現(xiàn)的菜單切換都比較單調(diào),因?yàn)閮H僅是一個(gè)簡(jiǎn)單的圖片的變化,不像很多flash菜單一樣變化非常的平滑,但是這里我們就是要用非flash的技術(shù)實(shí)現(xiàn)一個(gè)平滑的hover效果。2010-05-05jQuery實(shí)現(xiàn)鼠標(biāo)移到元素上動(dòng)態(tài)提示消息框效果
當(dāng)光標(biāo)移動(dòng)到某些元素上時(shí),會(huì)彈出像tips的提示框,這種效果想必大家都有見到過吧,下面有個(gè)不錯(cuò)的示例,大家可以感受下2013-10-10jquery實(shí)現(xiàn)點(diǎn)擊label的同時(shí)觸發(fā)文本框點(diǎn)擊事件的方法
這篇文章主要介紹了jquery實(shí)現(xiàn)點(diǎn)擊label的同時(shí)觸發(fā)文本框點(diǎn)擊事件的方法,涉及jQuery鼠標(biāo)事件及頁面元素操作的技巧,需要的朋友可以參考下2015-06-06jQuery實(shí)現(xiàn)定時(shí)讀取分析xml文件的方法
這篇文章主要介紹了jQuery實(shí)現(xiàn)定時(shí)讀取分析xml文件的方法,涉及jquery通過定時(shí)器采用Ajax方法讀取并處理XML文件的相關(guān)技巧,需要的朋友可以參考下2015-07-07基于jquery的inputlimiter 實(shí)現(xiàn)字?jǐn)?shù)限制功能
因客戶要求區(qū)分全角跟半角,所以在jquery.inputlimiter.js插件上還做了些小改動(dòng)。2010-05-05jQuery與vue實(shí)現(xiàn)拖動(dòng)驗(yàn)證碼功能
本篇文章主要給大家分享jQuery與vue分別實(shí)現(xiàn)超級(jí)簡(jiǎn)單的綠色拖動(dòng)驗(yàn)證碼功能以及代碼實(shí)例,需要的朋友學(xué)習(xí)下吧。2018-01-01