title: Find a string of text in an element and wrap some span tags round it
body: <p>I want to find a string of text in an element and wrap some span tags round it. E.g.</p>
  
  <p>From:</p>
  
  <pre><code>&lt;h2&gt;We have cows on our farm&lt;/h2&gt;
  </code></pre>
  
  <p>To:</p>
  
  <pre><code>&lt;h2&gt;We have &lt;span class='smallcaps'&gt;cows&lt;/span&gt; on our farm&lt;/h2&gt;
  </code></pre>
  
  <p>I've tried:</p>
  
  <pre><code>$("h2:contains('cow')").each(function() {
   $(this).text().wrap("&lt;span class='smallcaps'&gt;&lt;/span&gt;");
  });
  </code></pre>
  
  <p>But that only wraps the whole containing <code>h2</code> tag.</p>