//1.获取要高亮显示的行
var rowNode = $('.highlightRow');
//2.获取搜索的内容
var searchContent = $("#searchContent").val();
//3.遍历整行内容,添加高亮颜色
rowNode.each(function() {
var word = $(this).html();
word = word.replace(searchContent, '<span style="color:red;">' + searchContent + '</span>');
$(this).html(word);
});
jq利用replace()方法实现关键字高亮显示
猜你喜欢
转载自blog.csdn.net/qq_40924516/article/details/85157686
今日推荐
周排行