我试图实施搜索表,我在网上找到了答案,我试了一下,它工作正常!突出搜索文字与jquery
现在我想强调(改变文本颜色:文本颜色类=蓝色文本)该搜索关键字表格单元格中,我寻找这个答案,但我没有发现任何有用的!
我的HTML是
<table class="stdtable">
<tr>
<td id="stdname">Name</td>
<td id="stdreg">Reg. No.</td>
<td id="stdparent">Parent</td>
<td id="stdgrp">Group</td>
<td id="action">Action</td>
</tr>
</table>
和jQuery是
$("#filter").on("keyup", function() {
var searchKey = $(this).val().toLowerCase();
$(".stdtable tr #stdname").each(function() {
var searchStr = $(this).text().toLowerCase();
if (searchStr.indexOf(searchKey)!=-1) {
$(this).parent().show();
}
else {
$(this).parent().hide();
}
});
});
我怎么能凸显搜索文本? 如果我搜索ñ文本在名称无应该改变颜色
,如果我清除搜索字段我需要清除的文字颜色也
剥离跨度声明试试[大关。 JS](https://markjs.io/)? – dude