1
我有一个JS文件来搜索一张桌子。它工作正常,并在搜索时在页面上显示结果。PHP和jQuery在桌面上进行实时搜索问题
的Javascript:
function Search()
{
var $rows = $('#table tr');
$('#search').keyup(function() {
var val = '^(?=.*\\b' + $.trim($(this).val()).split(/\s+/).join('\\b)(?=.*\\b') + ').*$',
reg = RegExp(val, 'i'),
text;
$rows.show().filter(function() {
text = $(this).text().replace(/\s+/g, ' ');
return !reg.test(text);
}).hide();
});
}
HTML
<table class="table" id="table">
<input type="text" id="search" placeholder="Type to search" onkeyup="Search();">
<tr>
<th>Naam</th>
<th>Personeelsnummer</th>
<th>Geblokkeerd niveau</th>
<th>Wachtwoord</th>
<th>Verwijderen</th>
<th>(De)blokkeren</th>
</tr>
<?php
while ($row = mysqli_fetch_array($result)) {?>
<tr>
<td><?php echo $row['P_Naam'];?></td>
<td><?php echo $row['P_ID'];?></td>
<td><?php echo $row['P_Blocked'];?></td>
的代码都与上表中的一些更多的按钮。
问题是,当它返回搜索时表头消失。我一直在试图弄清楚问题是什么,但似乎无法弄清楚。
感谢您的快速输入,但我不知道我会怎么做..有没有办法可以排除这些标题? – Xianchu
尝试 - $('#table tr:not(:first)') –
谢谢!它解决了! – Xianchu