基于jquery實(shí)現(xiàn)表格內(nèi)容篩選功能實(shí)例解析
當(dāng)表格內(nèi)的數(shù)據(jù)較多時(shí),我們無法一頁一頁的查找,這時(shí)可以通過一個(gè)搜索框來實(shí)現(xiàn)搜索。
對于這個(gè)搜素框,我們?yōu)榱烁玫捏w驗(yàn)可以利用keyup事件實(shí)現(xiàn)在用戶輸入的時(shí)候就開始篩選,而不是填完以后點(diǎn)擊搜索按鈕再執(zhí)行。
效果圖:
實(shí)現(xiàn)代碼:
<html> <head> <meta charset="utf-8" /> <script src="jquery-1.3.2.min.js"></script> <link href="css/style.css" rel="stylesheet" type="text/css" /> <script> $(function () { $("tr.parent").click(function () { $(this) .siblings('.child_'+this.id).toggle(); }); $("tr.parent").addClass("selected"); $("#searchbox").keyup(function () { $("table tbody tr").hide() .filter(":contains('"+($(this).val())+"')").show();//filter和contains共同來實(shí)現(xiàn)了這個(gè)功能。 }).keyup(); }); </script> <title></title> </head> <body> <label>篩選</label> <input type="text" id="searchbox"/> <table> <thead> <tr><td>姓名</td><td>性別</td><td>暫住地</td></tr> </thead> <tbody> <tr class="parent" id="row_01"><td>前臺設(shè)計(jì)組</td></tr> <tr class="child_row_01"><td>張山</td><td>男</td><td>湖北</td></tr> <tr class="child_row_01"><td>李山</td><td>男</td><td>湖北</td></tr> <tr class="child_row_01"><td>張山</td><td>男</td><td>湖北</td></tr> <tr class="child_row_01"><td>張山</td><td>男</td><td>湖北</td></tr> <tr class="parent" id="row_02"><td>前臺設(shè)計(jì)組</td></tr> <tr class="child_row_02"><td>張山</td><td>男</td><td>湖北</td></tr> <tr class="child_row_02"><td>張山</td><td>男</td><td>湖北</td></tr> <tr class="child_row_02"><td>張山</td><td>男</td><td>湖北</td></tr> <tr class="child_row_02"><td>張山</td><td>男</td><td>湖北</td></tr> <tr class="parent" id="row_03"><td>前臺設(shè)計(jì)組</td></tr> <tr class="child_row_03"><td>張山</td><td>男</td><td>湖北</td></tr> <tr class="child_row_03"><td>張山</td><td>男</td><td>湖北</td></tr> <tr class="child_row_03"><td>張山</td><td>男</td><td>湖北</td></tr> <tr class="child_row_03"><td>張山</td><td>男</td><td>湖北</td></tr> </tbody> </table> </body> </html>
以上就是本文的全部內(nèi)容,希望對大家學(xué)習(xí)jquery程序設(shè)計(jì)有所幫助。
- 基于JQuery的一句代碼實(shí)現(xiàn)表格的簡單篩選
- 讓你的CSS像Jquery一樣做篩選的實(shí)現(xiàn)方法
- JQuery操作表格(隔行著色,高亮顯示,篩選數(shù)據(jù))
- jQuery篩選器children()案例詳解(圖文)
- jquery表格內(nèi)容篩選實(shí)現(xiàn)思路及代碼
- JQuery篩選器全系列介紹
- Jquery仿淘寶京東多條件篩選可自行結(jié)合ajax加載示例
- jquery遍歷數(shù)組與篩選數(shù)組的方法
- jquery遍歷篩選數(shù)組的幾種方法和遍歷解析json對象
- jquery實(shí)現(xiàn)多條件篩選特效代碼分享
相關(guān)文章
模仿jQuery each函數(shù)的鏈?zhǔn)秸{(diào)用
模仿jQuery each函數(shù)的鏈?zhǔn)秸{(diào)用實(shí)現(xiàn)代碼。2009-07-07jQuery EasyUI Tab 選項(xiàng)卡問題小結(jié)
這篇文章主要介紹了jQuery EasyUI Tab 選項(xiàng)卡問題小結(jié),在項(xiàng)目開發(fā)階段很多朋友都遇到過此問題,其實(shí)解決辦法很簡單的,下面小編給大家分享下問題原因及解決辦法,需要的朋友可以參考下2016-08-08jquery實(shí)現(xiàn)鼠標(biāo)滑過小圖時(shí)顯示大圖的方法
這篇文章主要介紹了jquery實(shí)現(xiàn)鼠標(biāo)滑過小圖時(shí)顯示大圖的方法,涉及圖片及鼠標(biāo)操作的技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-01-01jQuery實(shí)現(xiàn)簡單日期格式化功能示例
這篇文章主要介紹了jQuery實(shí)現(xiàn)簡單日期格式化功能,涉及jQuery調(diào)用javascript針對日期格式轉(zhuǎn)換擴(kuò)展實(shí)現(xiàn)日期格式化功能相關(guān)操作技巧,需要的朋友可以參考下2017-09-09jQuery實(shí)現(xiàn)簡單的日期輸入格式化控件
本文給大家分享的是javascript實(shí)現(xiàn)簡單的日期輸入格式化控件的方法和思路,非常的細(xì)致實(shí)用,推薦給小伙伴們2015-03-03