我想在表格中突出显示搜索到的字词。我也试过了包装和文字功能。
<script>
$(document).ready(function(){
$('.livesearch').on('keyup',function(){
var searchTerm = $(this).val().toLowerCase();
$('#searchlist tr').each(function(){
var lineStr = $(this).text().toLowerCase();
if(lineStr.indexOf(searchTerm) === -1){
$(this).hide();
}else{
$(this).show();
$("#searchlist .thead").show();
$("#searchlist tr td:contains('" + searchTerm + "')").find(searchTerm).html("<div class='test'>" + searchTerm + "</div>");
}
});
});
});
</script>