I want a certain div to be added as the last element in a list no matter what. Is there any way in which I can explicitly specify this?
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.
Get the parent of the list and add the new item to that parent as the last child.
Using plain javascript:
Mozilla documentation: https://developer.mozilla.org/En/DOM/Node.appendChild
If you want to add other items and still have this item be the last item, then you will have to add the new items before this last item or remove this item, append your new item, then append this one back again at the end.
Once you already have the last element in the list, if you then want to add a new element right before that last element, you can do it like this: