JQuery add a class to a table row depending on <td> value -


i need check text of values in table inside of div. if 1 of values inside <td></td> equals "invalid", want add class "red" <tr>.

the html looks -

<div id="mydiv"> <table>     <tbody>         <tr>             <td>1</td>            <td>good</td>               </tr>         <tr>                   <td>2</td>            <td>invalid</td>               </tr>         <tr>                   <td>3</td>            <td>good</td>               </tr>     </tbody> </table> </div> 

i have jquery find any table on page, , puts class on <td>. how can change add class <tr> inside <div>?

    jquery.each($('tbody tr td'), function () {         if (this.textcontent == "invalid") {             $(this).addclass("red");         }     }); 

thanks!

if (this.textcontent == "invalid") {       $(this).closest('tr').addclass("red"); } 

Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -