i want to select element that its index is greater than 3 and less than 6
ex: $("td:gt(3)") and $("td:lt(6)") ?
i want to select element that its index is greater than 3 and less
Share
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.
Just combine the two and it should work:
$("td:gt(3):lt(6)");You can use any number of pseudo-selectors. They will all apply.
However, note that the
sliceanswer will be far more efficient than this!Update
The above code is wrong. You need to swap round
:ltand:gtbecause after thegtselector is executed the set of matched elements is reduced and the indexes that:ltapplies to are different:However, as mentioned above,
slicewill be better, performance wise. If you’re interested in how much better that performance will be, I’ve put together a quick test. Here’s the results (sliceis nearly 4 times faster):