nth child selector in jquery
Posted
by Praveen Prasad
on Stack Overflow
See other posts from Stack Overflow
or by Praveen Prasad
Published on 2010-03-08T16:23:16Z
Indexed on
2010/03/08
16:36 UTC
Read the original article
Hit count: 493
jQuery
<table width="600px" id='testTable'>
<tr class="red"><td>this</td></tr>
<tr><td>1</td></tr>
<tr><td>1</td></tr>
<tr><td>1</td></tr>
<tr class="red"><td>1</td></tr>
<tr><td>1</td></tr>
<tr><td>1</td></tr>
<tr class="red"><td>this</td></tr>
<tr><td>1</td></tr>
<tr><td>1</td></tr>
<tr class="red"><td>1</td></tr>
<tr><td>1</td></tr>
<tr><td>1</td></tr>
</table>
.gray
{
background-color:#dddddd;
}
.red
{
color:Red;
}
$(function () {
$('#testTable tr.red:nth-child(odd)').addClass('gray');
//this should select tr's with text=this, but its not happening
});
i want to select all odds inside table which have class=red , but its not happening. please help
© Stack Overflow or respective owner