他想做一个带有过滤表选项的输入框。 我的输入框是:
<input class="form-control" id="myInput" type="text" placeholder="Search..">
这段代码生成一个表:
$data = '<table class="table table-bordered table-striped">
<tr>
<th>No.</th>
<th>Status</th>
<th>First Name</th>
<th>Last Name</th>
<th>Email Address</th>
<th>Update</th>
<th>Delete</th>
</tr>';
$query = "SELECT * FROM users";
我的js是:
$(document).ready(function(){
$("#myInput").on("keyup", function() {
var value = $(this).val().toLowerCase();
$("#myTable tr").filter(function() {
$(this).toggle($(this).text().toLowerCase().indexOf(value) > -1)
});
});
});
是否需要使用tbody或其他任何东西来做过滤表? 或者不可能为第一个做异常(exception)?
非常感谢!
最佳答案
是的,可以为第一个做异常(exception)。尝试这样的事情:
$('table tr:gt(1)').filter...
(您的标题有 1 行,因此可以正常工作)
关于javascript - 使用过滤表对第一个 td 执行异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47664466/