title: Exclude child elements from functions with jquery
body: <p>With the code below:</p>
  
  <pre><code>&lt;p&gt;Red red red red &lt;a href="http://www.google.com"&gt; this should be red alone&lt;/a&gt; red red&lt;/p&gt;
  </code></pre>
  
  <p>How would I change all 'red's to 'yellow's EXCEPT the one in the 'a' tag?</p>
  
  <p>I've got this far:</p>
  
  <pre><code>$("p").html(function(i,event){
      return event.replace(/(red)/g,'yellow');
  });
  </code></pre>
  
  <p>...which changes everything to yellow. I assume I need to add in an if clause saying something along the lines of:</p>
  
  <pre><code>if (event.target.tagName === "a")
  {return false}
  </code></pre>
  
  <p>But I've tried dozens of things I've found on stackoverflow, to no effect. Any ideas?</p>