how do I strip white space when grabbing text with jQuery?
<p>I'm wanting to use jQuery to wrap a mailto: anchor around an email address, but it's also grabbing the whitepace that the CMS is generating.</p>

<p>Here's the HTML I have to work with, the script as I have it and a copy of the output.</p>

<p>html</p>

<pre><code>&lt;div class="field field-type-text field-field-email"&gt;
  &lt;div class="field-item"&gt;
    name@example.com    &lt;/div&gt;
&lt;/div&gt;
</code></pre>

<p>jQuery JavaScript</p>

<pre><code>$(document).ready(function(){
  $('div.field-field-email .field-item').each(function(){
    var emailAdd = $(this).text();
      $(this).wrapInner('&lt;a href="mailto:' + emailAdd + '"&gt;&lt;/a&gt;');
   });
 });
</code></pre>

<p>Generated HTML</p>

<pre><code>&lt;div class="field field-type-text field-field-email"&gt;
  &lt;div class="field-items"&gt;&lt;a href="mailto:%0A%20%20%20%20name@example.com%20%20%20%20"&gt;
    name@example.com    &lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
</code></pre>

<p>Though I suspect that others reading this question might want to just strip the leading and tailing whitespace, I'm quite happy to lose all the whitespace considering it's an email address I'm wrapping.</p>

<p>Cheers,<br />
Steve</p>
