Look at this:
var selection= $('table td:first-child');
In practice it selects the first row’s <td> elements in the table.
When I saw it for the first time, I took it as: Select all first-child elements within all <td> in the <table> </table>.
But what it does is: Select all <td> within the table if it is the first-child of its parent. Means first <td> between each tags.
So, the question is, does first-child selector works like a flag? Or it works like a kind of method to get the first-child of the element in question in the jQuery wrapper-set?
thanks,
Firstchild will get the
TDwithin the table that are the first child within their parent. If you wanted what you intially though it’d be something liketable td > *:first-child. Think of it like the rest of the:filters jQuery provides: hidden, disabled, checked, etc. It applies to the element in the selector it is attached to.