In jquery, say I have an html selector select. Which is faster to get the ith element from the selector? If one is faster, how much faster? By a little or a lot?
select.children[i]
Or
$j('*:nth-child(' + i + ')', select)
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.
select.children[i]is way faster. This is because it doesn’t have the overhead of jQuery. Here’s a jsPerf, where you can see the results.For the first test i used
And the second