nth child selector in jquery
- by Praveen Prasad
<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