Suppose I have this HTML structure:
<table>
<tr>
<td></td>
<td></td>
<td class="hasDay"><div class="day">1 <!--This is what needs selected--></div></td>
<td class="hasDay"><div class="day">2</div></td>
<td class="hasDay"><div class="day">3</div></td>
<td class="hasDay"><div class="day">4</div></td>
<td class="hasDay"><div class="day">5</div></td>
</tr>
...
</table>
So I need to select via jQuery the first .day in the first td with the class .hasDay. I've tried the following:
$("tr .hasDay:first-child .day")
Looping through every td in the tr, stopping when it gets to .day and using $(this) to select it.
How do it do it?
Try
:first-of-type:And also
.first()jQuery function works!Snippet