开发者

Full text search jquery -highlight yellow background

开发者 https://www.devze.com 2023-02-19 18:43 出处:网络
i have in my asp.net page a textarea where users type an article=\"long text\" to be saved in the database. In another page i display these articles(textarea) in a :

i have in my asp.net page a textarea where users type an article="long text" to be saved in the database. In another page i display these articles(textarea) in a :

  <p clas开发者_运维问答s="p-article">
      the text of the article goes here.

  </p>

I'd like to filter these articles by search keywords .for example when a user search for "Startup Marketing".

I want to apply the keywords as a filter and get articles and bring those that contain "Startup" or "Marketing" or "Startup Marketinbg".And this in client side by jquery if possible.


This may help

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>");
});
});
0

精彩评论

暂无评论...
验证码 换一张
取 消