Hi All,
consider the following div is inside body tag.
<div id="test">
this is <a href="#">my</a> text that needs highlighting
</div>
Now to highlight the term '
mytext 'and re assign the inner html to the div, javascript code is :
--------------------------------
var src_str = $("#test").html();
var term = "my text";
term = term.replace(/(\s+)/,"(<[^>]+>)*$1(<[^>]+>)*");
var pattern = new RegExp("("+term+")", "i");
src_str = src_str.replace(pattern, "<mark>$1</mark>");
src_str = src_str.replace(/(<mark>[^<>]*)((<[^>]+>)+)([^<>]*<\/mark>)/,"$1</mark>$2<mark>$4");
$("#test").html(src_str);
This is fine .
--------------------------------
Now my requirement has changed to highlight '
mytext' in following div.
<div id="test">
this is <nobr>my</nobr><nobr>text that needs highlighting</nobr>
</div>
Please provide me solution as early as possible.
Thank you,
Govind