$(".wrap table tr:first").addClass("tr-top");
it works for the first table, but i have many tables under the div .wrap.
what should i do? thanks!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In your example, this line returns the first in the set of all
trelements found.So if you have 3
tableelements, it will only return the firsttrfrom the first table, since that will be the firsttrelement matched.If you want the first
trfor each table, you needfirst-child:…which will return each
trthat is a first child of its parent.http://api.jquery.com/first-selector/
http://api.jquery.com/first-child-selector/