Search & Highlight using JQuery -



Search & Highlight using JQuery -

i need highlight searched text when page loaded , whole words match specific word highlighted .

i know can utilize id of div & accordingly highlight field .

the issue here have complex construction of div have found on google works on "p:"

var str = "test"; $(function(){ $('p:contains('+str+')'). each(function(){ var regex = new regexp(str, "g"); $(this).html( $(this).html(). replace( regex , "<span class='highlight'>"+str+"</span>" ) ); }); });

i have tried mess code loop on div instead , couldn't reach solution

i have found reply solution here .

jquery

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

c# - Can ProtoBuf-Net deserialize to a flat class? -

javascript - Change element in each JQuery tab to dynamically generated colors -