我試圖實施搜索表,我在網上找到了答案,我試了一下,它工作正常!突出搜索文字與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