 <p>This problem is actually caused by HTML behaving differently then JQuery. In HTML, spaces and extra lines don't matter. </p> <p>In HTML, these 2 examples are visually the same when rendered to the page:</p> <pre><code>&lt;div id="vendor"&gt;Barracuda&lt;/div&gt; </code></pre> <p>and</p> <pre><code>&lt;div id="vendor"&gt; Barracuda &lt;/div&gt; </code></pre> <p>However when you use JQuery's .Text() method, they yield different results.</p> <pre><code>&lt;div id="vendor"&gt;Barracuda&lt;/div&gt; $('#vendor').text() // equals "Barracuda" </code></pre> <p>But this is very different:</p> <pre><code>&lt;div id="vendor"&gt; Barracuda &lt;/div&gt; $('#vendor').text() // equals " Barracuda " </code></pre> <p>Thus the need to .trim() the results if you can't tailor the HTML, or just want to play it safe.</p> <pre><code>var thisText = $.trim($(this).text()); </code></pre> <p><a href="http://jsfiddle.net/usy8F/" rel="nofollow">JSFiddle Working Example</a></p>