javascript - Apply CSS to TR if certain style is in a TD -


as title says, need addclass() tr (the tr, if multiple) if td has class.

example:

<table>   <tr>     <td>test</td>     <td>1</td>     <td>2</td>     <td>3</td>   </tr>   <tr>     <td class="scratched">test</td>     <td>1</td>     <td>2</td>     <td>3</td>   </tr>   <tr>     <td>test</td>     <td>1</td>     <td>2</td>     <td>3</td>   </tr>   <tr>     <td class="scratched">test</td>     <td>1</td>     <td>2</td>     <td>3</td>   </tr> </table> 

so if td has class "scratched", apply class "line" tr.

use .has() filter:

$('tr').has('td.scratched').addclass('line'); 

see jsfiddle example.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

javascript - addthis share facebook and google+ url -

ios - Show keyboard with UITextField in the input accessory view -