Using javascript to insert links in text WITHOUT replacing entire content of div
<p>I'm writing a widget that searches for specific keywords in a specified "#content" div. </p>

<p>Here is how I set it up originally using jQuery (simplified version):</p>

<ul>
<li>set a variable equal to the html of the content: <code>var content = $('content').html();</code></li>
<li>use some regexes to replace certain keywords with <code>&lt;a href='link.html'&gt;keyword&lt;/a&gt;</code></li>
<li>replace the html of the content div with the new content: <code>$('content').html(content);</code></li>
</ul>

<p>This works for the most part, but the problem occurs when the "#content" div contains javascript. When I set <code>$('content').html(content)</code>, it re-runs any javascript code contained in the <code>$('content')</code> div, which can cause errors. Since this is a widget that I'm writing to work on any site, I don't have control over the content div, and whether there will be any javascript in it.</p>

<p>My questions is, is there a way to replace JUST the keywords with <code>&lt;a href='link.html'&gt;keyword&lt;/a&gt;</code>, WITHOUT replacing the entire content of the div?</p>
