【发布时间】:2012-09-08 04:02:46
【问题描述】:
假设我有一个标准的 HTML 表格结构,例如:
<table class="table table-striped table-hover table-bordered table-condensed">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Added</th>
</tr>
</thead>
<tbody>
<tr id="1a0daa2734" class="item">
<td><a href="/view/1a0daa2734">Item Number 1</a></td>
<td>A</td>
<td>8/1/2012 10:18:34 PM</td>
</tr>
<tr id="b1ff6e0ac" class="item">
<td><a href="/view/b1ff6e0ac">Item Number 2</a></td>
<td>B</td>
<td>8/2/2012 5:48:54 PM</td>
</tr>
<tr id="edd8b70893" class="item">
<td><a href="/view/edd8b70893">Item Number 3</a></td>
<td>A</td>
<td>8/13/2012 3:55:41 PM</td>
</tr>
</tbody>
</table>
我正在尝试使用 jQuery 编写客户端搜索。基本上我有一个 id 为search-items 的搜索框。
$("#search-items").bind("keyup paste", function() {
var searchText = $("#search-items").val();
$(".item").each(function() {
//???
});
});
获取search-items 的搜索值并在tbody 内找到NON-MATCHES 的最佳方法是什么?我想要不匹配的,因为这些是我要隐藏的元素。
它应该只在前两个td 元素内搜索,所以name 和type 列,不添加。
谢谢。
【问题讨论】:
标签: javascript jquery html search