Reputation: 91
As title says, need to addclass()
to a tr
(the tr
, if multiple) if the td
has a certain 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 the td has class "scratched", apply class "line" to the tr.
Upvotes: 0
Views: 258
Reputation: 46307
Use the .has()
filter:
$('tr').has('td.scratched').addClass('line');
See jsFiddle for example.
Upvotes: 3
Reputation: 28773
Try with .parent()
like
$('td.scratched').parent('tr').addClass('line');
See the DEMO
Upvotes: 0
Reputation: 10608
Something along the lines of:
$('td.scratched').parent().addClass('line');
should work.
Upvotes: 2