how to apply background color to the found text
<p>hello i have following code and it works fine for finding and replacing string... but it is not working globally..how to make it to work as globally and after replacing i want to highlight that string into green color.. how..?</p>

<pre><code>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
&lt;html&gt;
 &lt;head&gt;
  &lt;title&gt; New Document &lt;/title&gt;
 &lt;script type="text/javascript" src="../js/jquery-1.4.2.min.js"&gt;&lt;/script&gt;
 &lt;script&gt;
$(document).ready(function(){
$('#replace').click(function(){
var oldstr=$('#inputstring').val();
var newstr=$('#newstring').val();
var para=$('#para').html();
var result=$('p:contains('+oldstr+')');


if(result)
{
var x=para.replace(new RegExp(oldstr, 'i','g'), newstr);
$('#para').empty().html(x);

}
})
})
 &lt;/script&gt;
 &lt;/head&gt;

 &lt;body&gt;
  Enter the string to find:&lt;input type="text" id="inputstring"&gt;&lt;br&gt;
  Enter string to replace:&lt;input type="text" id="newstring"&gt;&lt;br&gt;
  &lt;input type="button" value="Replace" id="replace"&gt;&lt;br&gt;
  &lt;p id="para"&gt;This is the new paragraph written to test how to replace the a string  with desired string&lt;/p&gt;
 &lt;/body&gt;
&lt;/html&gt;
</code></pre>
