jquery表格內(nèi)容篩選實(shí)現(xiàn)思路及代碼
更新時間:2013年04月16日 15:28:21 作者:
基于jquery實(shí)現(xiàn)表格內(nèi)容篩選,本文采用兩種方式實(shí)現(xiàn),感興趣的朋友可以參考下哈,希望對你學(xué)習(xí)jquery篩選有所幫助
復(fù)制代碼 代碼如下:
篩選:<input type="text" id="sea" />
<table width="100%" id="se">
<thead>
<tr><th></th><th>姓名</th><th>性別</th><th>地址</th></tr>
</thead>
<tbody>
<tr class="parent" id="row_01"><td colspan="3">一班</td></tr>
<tr class="child_row_01"><td></td><td>大爺</td><td>男10</td><td>武漢1</td></tr>
<tr class="child_row_01"><td></td><td>大爺</td><td>男9</td><td>武漢2</td></tr>
<tr class="child_row_01"><td></td><td>大爺</td><td>男8</td><td>武漢3</td></tr>
<tr class="parent" id="row_02"><td colspan="3">二班</td></tr>
<tr class="child_row_02"><td></td><td>大爺</td><td>男7</td><td>武漢4</td></tr>
<tr class="child_row_02"><td></td><td>大爺</td><td>男6</td><td>武漢5</td></tr>
<tr class="child_row_02"><td></td><td>大爺</td><td>男5</td><td>武漢6</td></tr>
<tr class="child_row_02"><td></td><td>大爺</td><td>男4</td><td>武漢7</td></tr>
<tr class="parent" id="row_03"><td colspan="3">三班</td></tr>
<tr class="child_row_03"><td></td><td>大爺</td><td>男3</td><td>武漢8</td></tr>
<tr class="child_row_03"><td></td><td>大爺</td><td>男2</td><td>武漢9</td></tr>
<tr class="child_row_03"><td></td><td>大爺</td><td>男1</td><td>武漢10</td></tr>
</tbody>
</table>
<script type="text/javascript" >
$(function(){
$("#sea").keyup(function(){
$("#se tbody tr").hide().filter(":contains('"+$(this).val()+"')").show();
}).keyup();
});
</script>
復(fù)制代碼 代碼如下:
// jquery表格內(nè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" />
<script src="../css/jquery-1.6.2.js"></script>
<script>
$(function(){
$('tr.parent').click(function(){
$(this).toggleClass("selected").siblings('.child_'+this.id).toggle();
});
});
</script>
<style>
.selected{background:red};
</style>
<title>Untitled Document</title>
</head>
<body>
<table>
<thead>
<tr>
<th>姓名</th>
<th>年齡</th>
</tr>
</thead>
<tbody>
<tr class="parent" id="row_01">
<td colspan="2">人力部</td>
</tr>
<tr class="child_row_01">
<td >腳本</td>
<td>20</td>
</tr>
<tr class="child_row_01">
<td >腳本</td>
<td >20</td>
</tr>
<tr class="child_row_01">
<td >腳本</td>
<td >20</td>
</tr>
<tr class="parent" id="row_02">
<td colspan="2">技術(shù)部</td>
</tr>
<tr class="child_row_02">
<td >腳本</td>
<td >20</td>
</tr>
<tr class="child_row_02">
<td >腳本</td>
<td >20</td>
</tr>
<tr class="child_row_02">
<td >腳本</td>
<td >20</td>
</tr>
</tbody>
</table>
</body>
</html>
您可能感興趣的文章:
- JQuery篩選器全系列介紹
- jQuery篩選器children()案例詳解(圖文)
- jquery遍歷篩選數(shù)組的幾種方法和遍歷解析json對象
- jQuery多條件篩選如何實(shí)現(xiàn)
- jquery實(shí)現(xiàn)多條件篩選特效代碼分享
- jQuery選擇器之屬性篩選選擇器用法詳解
- 基于jQuery實(shí)現(xiàn)表格內(nèi)容的篩選功能
- 基于JQuery的一句代碼實(shí)現(xiàn)表格的簡單篩選
- JS Jquery 遍歷,篩選頁面元素 自動完成(實(shí)現(xiàn)代碼)
- jquery數(shù)組過濾篩選方法grep()簡介
- jQuery 篩選器簡單操作示例
相關(guān)文章
jquery調(diào)用asp.net 頁面后臺的實(shí)現(xiàn)代碼
前一篇介紹jquery調(diào)用webservice,這一篇引用的是用jquery直接調(diào)用aspx后臺方法。2011-04-04
jquery $.ajax()取xml數(shù)據(jù)的小問題解決方法
今天想做一個用$.ajax()從xml中讀取數(shù)據(jù)的這么一個異步交互過程2010-11-11
jquery validate表單驗(yàn)證的基本用法入門
這篇文章主要為大家介紹了jquery validate表單驗(yàn)證的基本用法入門,jQuery Validate 插件為表單提供了強(qiáng)大的驗(yàn)證功能,讓客戶端表單驗(yàn)證變得更簡單,同時提供了大量的定制選項(xiàng),滿足應(yīng)用程序各種需求,感興趣的小伙伴們可以參考一下2016-01-01
jQuery實(shí)現(xiàn)仿騰訊迷你首頁選項(xiàng)卡效果代碼
這篇文章主要介紹了jQuery實(shí)現(xiàn)仿騰訊迷你首頁選項(xiàng)卡效果代碼,可實(shí)現(xiàn)tab切換按鈕的左右滑動顯示及點(diǎn)擊切換效果,涉及jQuery基于鼠標(biāo)事件實(shí)現(xiàn)頁面元素動態(tài)操作技巧,需要的朋友可以參考下2015-09-09
HTML+jQuery實(shí)現(xiàn)簡單的登錄頁面
這篇文章主要介紹了用三種方法實(shí)現(xiàn)簡單的登錄頁面的制作:純HTML、HTML+jQuery(form data)格式、HTML+jQuery(json)格式。感興趣的同學(xué)可以跟隨小編一起學(xué)習(xí)一下2021-12-12

