JQuery表格内容过滤的实现方法
代码如下:
[html] <!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> <style type="text/css"> table{ border:0;border-collapse:collapse;} div{font:normal 12px/17px Arial;} td{ font:normal 12px/17px Arial;padding:2px;width:100px;} th{ font:bold 12px/17px Arial;text-align:left;padding:4px;border-bottom:1px solid #333;width:100px;} .even{ background:#FFF38F;} /* 偶数行样式*/ .odd{ background:#FFFFEE;} /* 奇数行样式*/ .selected{ background:#FF6500;color:#fff;} </style> <!-- 引入jQuery --> <script src="jquery-1.5.2.min.js" type="text/javascript"></script> <script type="text/javascript"> $(function(){ $("#filterName").keyup(function(){ $("table tbody tr") .hide() .filter(":contains('"+( $(this).val() )+"')") .show(); }).keyup(); }) </script> </head> <body> <div> <br/> 筛选: <input id="filterName" name="filterName" /> <br/> </div> <table> <thead> <tr><th>姓名</th><th>性别</th><th>暂住地</th></tr> </thead> <tbody> <tr><td>SYJ</td><td>男</td><td>河北秦皇岛市</td></tr> <tr><td>李四</td><td>女</td><td>北京北京市</td></tr> <tr><td>王五</td><td>男</td><td>河北秦皇岛市</td></tr> <tr><td>赵六</td><td>男</td><td>河北唐山市</td></tr> <tr><td>张三</td><td>男</td><td>内蒙古呼和浩特市</td></tr> <tr><td>王六</td><td>女</td><td>内蒙古包头市</td></tr> <tr><td>二狗</td><td>男</td><td>北京北京市</td></tr> <tr><td>李字</td><td>女</td><td>河北秦皇岛市</td></tr> <tr><td>二蛋</td><td>男</td><td>东北辽宁省</td></tr> </tbody> </table> </body> </html>
相关推荐
momode 2020-09-11
EdwardSiCong 2020-11-23
85477104 2020-11-17
hhanbj 2020-11-17
81427005 2020-11-11
seoppt 2020-09-13
honeyth 2020-09-13
WRITEFORSHARE 2020-09-13
84483065 2020-09-11
85477104 2020-08-15
83510998 2020-08-08
82550495 2020-08-03
tthappyer 2020-08-03
84901334 2020-07-28
tthappyer 2020-07-25
TONIYH 2020-07-22
tztzyzyz 2020-07-20
83510998 2020-07-18
81463166 2020-07-17