for example,we have
<ul><li></li><li></li>....</ul>
we don’t know how many li tag in these code and right now i have a reference to one of these li elements.
is there a simple way to know if this reference is the last item?
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.
You can use the
:last-childselector, and check if the element matches it:You should replace the
'li'selector above with your reference to the element.Note that replacing it is necessary, since
.is()will return true if any of the elements in the matched set matches the new selector, so you really only want to call it on your specific list-item.