Match a String in a Webpage along with HTML tags
<p>With below code, I am trying to match a text in a web page to get rid of html tags in a page.  </p>

<pre><code>   var body = $(body);
   var str = "Search me in a Web page";
   body.find('*').filter(function()
   {
     $(this).text().indexOf(str) &gt; -1;
   }).addClass('FoundIn');
   $('.FoundIn').text() = $('.FoundIn').text().replace(str,"&lt;span class='redT'&gt;"+str+"&lt;/span&gt;"); 
</code></pre>

<p>But it does not seems to work.. Please have a look at this and let me know where the problem is...<br>
<a href="http://jsfiddle.net/m4vXx/" rel="nofollow">here</a> is the fiddle 
I have tried the below code instead.. </p>

<pre><code>function searchText() 
 {
  var rep = body.text();
  alert(rep);
  var temp = "&lt;font style='color:blue; background-color:yellow;'&gt;";
  temp = temp + str;
  temp = temp + "&lt;/font&gt;";
  var rep1 = rep.replace(str,temp);
  body.html(rep1);
 }
</code></pre>

<p>But that is totally removing html tags from body...</p>
