I have this working code:
a.parentNode.removeChild(a);
I need to also remove this child’s previous sibling, i.e. the element that comes before it.
How do I update this? Does MDN have documentation on it?
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.
Ok, here is a solution which takes into account that the previous sibling might not be an element node:
Reference:
Node.previousSibling[MDN]You could easily create a function which gives you the previous element node.
I will repeat my comment here:
You can find a reference of all DOM interfaces at MDN, in particular, the
Nodeinterface.