我在我的asp.net页面中有一个textarea,其中用户键入要保存在数据库中的article =“long text”。在另一个页面中,我在:
中显示这些文章(textarea) <p class="p-article">
the text of the article goes here.
</p>
我想通过搜索关键字过滤这些文章。例如,当用户搜索“启动营销”时。
我想将关键字应用为过滤器并获取文章并带来包含“Startup”或“Marketing”或“Startup Marketinbg”的文章。如果可能,请在客户端使用jquery。
答案 0 :(得分:2)
这可能会有所帮助
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>");
});
});