jQuery not comparing variables correctly in table cells
<p>I have a table like this:</p>

<pre><code>&lt;table id="comparison"&gt;
    &lt;tr&gt;
        &lt;th&gt;Hotels&lt;/th&gt;
        &lt;th&gt;Jan 2013&lt;/th&gt;
        &lt;th&gt;Feb 2013&lt;/th&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;Lorem Ipsum Hotel&lt;/td&gt;
        &lt;td&gt;
            &lt;div class="rooms"&gt;165&lt;/div&gt;
            &lt;div class="sob"&gt;352&lt;/div&gt;
        &lt;/td&gt;
        &lt;td&gt;
            &lt;div class="rooms"&gt;215&lt;/div&gt;
            &lt;div class="sob"&gt;30&lt;/div&gt;
        &lt;/td&gt;
    &lt;/tr&gt;
&lt;/table&gt;
</code></pre>

<p>I prepared this jQuery script to compare the Rooms and SOB in each cell.<br />
- If the SOB is less than the Rooms then I color the SOB red to signal a negative result.<br />
- If the SOB is greater than the Rooms then I color SOB green to signal a positive result.</p>

<pre><code>$('#comparison td .sob').each(function() {
    var rooms = $(this).prev().text();
    var sob = $(this).text();
    if (rooms &gt; sob) {
        $(this).css({'color': 'red'});
    } else {
        $(this).css({'color': 'green'});
    }
});
</code></pre>

<p>The problem is that this script is not comparing the Rooms and SOB correctly. It seems to be running at random in the variable comparison, sometimes producing the correct result and other times not.</p>

<p>What am I missing?</p>
