Use a regex: $('body').html( $('body').html().replace(/(got|the)/g,'<b>$1</b>') );
On Apr 28, 9:39 am, kazim mehdi <kazim.me...@gmail.com> wrote: > hi > by using the following code i am able to find only first occurrences > of the keywords can anyone help me to make it work for all of the > occurrences. > > thank you > > function test() > { > var keywords = ["got", "the"]; > var el = $("body"); > $(keywords).each(function() > { > el.html(el.html().replace(this, > "<b>"+this+"</b>")); > }); > > }