Search and Replace All Instances of text that has the same name
<p>I am trying to do a search and replace of text that has the same name inside the body
but it is partial working, some of the text is being replace, but then some of the old text still show up, not quite sure what is going on.</p>

<pre><code>$(document).ready(function() {
    $('*').each(function(){
        if($(this).children().length == 0) 
            $(this).text($(this).text().replace("old text", "replace with new text"));
        });
});
</code></pre>

<p>much help is appreciated</p>

<p>thanks</p>
