<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>表格内容的筛选</title>
<script type="text/javascript" src="jss/jquery-1.3.2.min.js"></script>
</head>
<body>
<table width="260" border="1" align="center">
<thead align="center" valign="bottom">
<tr>
<td colspan="2">搜索:<input type="text" name="keyword" id="keyword" /></td>
</tr>
<tr bgcolor="#B2B2B2">
<td>姓名</td>
<td>成绩</td>
</tr>
</thead>
<tbody align="center" bgcolor="#FFFF88">
<tr>
<td>王一博</td>
<td>97</td>
</tr>
<tr>
<td>肖战</td>
<td>91</td>
</tr>
<tr>
<td>雷佳音</td>
<td>91</td>
</tr>
<tr>
<td>王俊凯</td>
<td>84</td>
</tr>
<tr>
<td>王源</td>
<td>97</td>
</tr>
<tr>
<td>易烊千玺</td>
<td>88</td>
</tr>
</tbody>
</table>
<script>
$(function(){
$("#keyword").keyup(function(){
if($("#keyword").val() != ''){
$("table tbody tr").hide().filter(":contains('"+($(this).val())+"')").show(); // 显示指定元素
}
})
})
</script>
</body>
</html>
表格内容的筛选
最新推荐文章于 2023-04-13 19:57:52 发布