jquery: Change the background-colour of a column if its header has a class
<p>I have the following jQuery that I'm trying to use to change the background colour of a column where its header has a class.</p>

<p>So for example:</p>

<pre><code>$('th').each(function (i) {

            if ($(this).hasClass('headerSortUp') || $(this).hasClass('headerSortDown')) {
                sortIndex = $(this).index();
            }
            $('tr').each(function () {
                $('td:eq(' + sortIndex + ')').css('background-color', 'orange');
            });

        });
</code></pre>

<p>So if I had a table like:</p>

<pre><code>&lt;table&gt;
&lt;tr&gt;
    &lt;th class="headerSortDown"&gt;Header&lt;/th&gt;
    &lt;th&gt;Header&lt;/th&gt;
    &lt;th&gt;Header&lt;/th&gt;
    &lt;th&gt;Header&lt;/th&gt;
    &lt;th&gt;Header&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
    &lt;td&gt;Text&lt;/td&gt;
    &lt;td&gt;Text&lt;/td&gt;
    &lt;td&gt;Text&lt;/td&gt;
    &lt;td&gt;Text&lt;/td&gt;
    &lt;td&gt;Text&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
    &lt;td&gt;Text&lt;/td&gt;
    &lt;td&gt;Text&lt;/td&gt;
    &lt;td&gt;Text&lt;/td&gt;
    &lt;td&gt;Text&lt;/td&gt;
    &lt;td&gt;Text&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
    &lt;td&gt;Text&lt;/td&gt;
    &lt;td&gt;Text&lt;/td&gt;
    &lt;td&gt;Text&lt;/td&gt;
    &lt;td&gt;Text&lt;/td&gt;
    &lt;td&gt;Text&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
</code></pre>

<p>So in this example the whole first column should have a bg of orange. However it's not working... Any ideas what I have done wrong? Thanks</p>
