我在我的 asp.net 页面中有一个文本区域,用户可以在其中键入要保存在数据库中的文章 =“长文本”。在另一个页面中,我将这些文章(文本区域)显示在:
<p class="p-article">
the text of the article goes here.
</p>
我想通过搜索关键字过滤这些文章。例如,当用户搜索“Startup Marketing”时。
我想将关键字用作过滤器并获取文章并带来包含“Startup”或“Marketing”或“Startup Marketinbg”的文章。如果可能的话,这在客户端通过 jquery。
最佳答案
这可能有帮助
var keyword = $("#searchtextbox").val().split(' ');
$.each(keyword,function(){
$(".p-article").html(function(index,oldhtml){
return oldhtml.replace(keyword,"<span style='background-color:Yellow'>"+keyword+"</span>");
});
});
关于c# - 全文搜索jquery-高亮黄色背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5443823/