Tuesday, April 28, 2009

[jQuery] find and replace

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

}

No comments: