0
我有许多名称的信息表。第一栏是名,第二栏是姓,第三栏是号码。我想根据用户输入显示所有行,但只希望搜索过滤器通过具有id的特定列。按特定列jQuery表格过滤器
jQuery代码:我有:
(document.ready(function()
$("#searchHere").keyup(function() {
var $row = $("table tr");
var $col = $("td").each().index();
var input = this.value.toLowerCase();
$row.show().filter(function() {
$(this).find("td").eq(col).text().toLowerCase();
return $(this).text(input);
}).hide();
});
的HTML代码
<input id="searchHere" placeholder="Search Me">
<table>
<tr>
<td id='firstName'>John</td>
<td id='lastName'>Doe</td>
<td>One Two Three</td>
</tr>
<tr>
<td id='firstName'>John</td>
<td id='lastName'>Smith</td>
<td>Two Three</td>
</tr>
</table>
我已经提到这个职位,但我想不通的最后一块拼图。
How to perform a real time search and filter on a HTML table
是的,我切换到1搜索栏浏览所有的TD ID。 – bryan151
如果这已回答您的问题,请通过单击打勾将其标记为解决方案。很高兴我能帮上忙 :) – swiss196