JQuery add a class to a table row depending on <td> value
<p>I need to check the text of values in a table inside of a div. If one of values inside a <code>&lt;td&gt;&lt;/td&gt;</code> equals "INVALID", I want to add the class "red" to the <code>&lt;tr&gt;</code>.</p>

<p>The html looks like this -</p>

<pre><code>&lt;div id="MyDiv"&gt;
&lt;table&gt;
    &lt;tbody&gt;
        &lt;tr&gt; 
           &lt;td&gt;1&lt;/td&gt;
           &lt;td&gt;GOOD&lt;/td&gt;      
        &lt;/tr&gt;
        &lt;tr&gt;       
           &lt;td&gt;2&lt;/td&gt;
           &lt;td&gt;INVALID&lt;/td&gt;      
        &lt;/tr&gt;
        &lt;tr&gt;       
           &lt;td&gt;3&lt;/td&gt;
           &lt;td&gt;GOOD&lt;/td&gt;      
        &lt;/tr&gt;
    &lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
</code></pre>

<p>I have JQuery which will find <em>any</em> table on the page, and puts the class on the <code>&lt;td&gt;</code>. How can I change this to add the class to the <code>&lt;tr&gt;</code> inside a certain <code>&lt;div&gt;</code>?</p>

<pre><code>    jQuery.each($('tbody tr td'), function () {
        if (this.textContent == "INVALID") {
            $(this).addClass("red");
        }
    });
</code></pre>

<p>Thanks!</p>
