Jquery Parent Item of Div containing X content.

Posted by fighella on Stack Overflow See other posts from Stack Overflow or by fighella
Published on 2010-04-15T06:29:59Z Indexed on 2010/04/15 6:33 UTC
Read the original article Hit count: 229

Filed under:

I need to add a CSS class to the TR (or multiple TR's) of the parent of a TD containing some specific text.

Because of the CMS I can't control the code, but I can add some Jquery and CSS.

I've tried a few things, but I've had no luck.

Here is an example of what I had in mind.

<style>
  tr.highlight { background: Blue;}
</style>

<table>
  <tr>
    <td>
      Pet
    </td>
    <td>
     Number of Legs
    </td>
  </tr>
  <tr>
    <td>
      Cat
    </td>
    <td>
      4
    </td>
  </tr>
  <tr>
    <td>
      Doggie
    </td>
    <td>
      4
    </td>
  </tr>
</table>

And I essentially want the jquery to add that class (highlight) to the offending TR.

** I know this is not an ideal approach, but desperate times call for desperate measures. **

Thanks for your help.

© Stack Overflow or respective owner

Related posts about jQuery