码迷,mamicode.com
首页 > Web开发 > 详细

Jquery在表格中搜索关键字

时间:2017-09-16 18:44:32      阅读:213      评论:0      收藏:0      [点我收藏+]

标签:border   func   关键字   rtx   type   input   ext   order   function   

<!DOCTYPE html>
<html>
<head>
<title>ddd</title>
</head>
<body>
<table border="1">

<thead>
<tr colspan="3">
<input type="text" id="filtertxt">
<input type="button" id="ss" value="搜索" style="margin-left: 50px;"/>
</tr>
<tr><th>姓名</th><th>性别</th><th>暂住地</th></tr>
</thead>
<tbody>
<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>Rain</td><td>男</td><td>浙江杭州</td></tr>
<tr><td>MAXMAN</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>
<script type="text/javascript" src="jquery-3.2.1.min.js"></script>
<script type="text/javascript">
$(function(){
$(‘#ss‘).click(function(){
var sstxt=$(‘#filtertxt‘).val();
$("table tbody tr")
.hide()
.filter(":contains(‘"+sstxt+"‘)")
.show();
})

})
</script>
</html>

Jquery在表格中搜索关键字

标签:border   func   关键字   rtx   type   input   ext   order   function   

原文地址:http://www.cnblogs.com/bing2017/p/7531947.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!