Categories
JavaScript Answers

How to remove the parent element using plain JavaScript?

Spread the love

Sometimes, we want to remove the parent element using plain JavaScript.

In this article, we’ll look at how to remove the parent element using plain JavaScript.

How to remove the parent element using plain JavaScript?

To remove the parent element using plain JavaScript, we call the parentElement.remove method.

For instance, we write

el.parentElement.remove();

to call parentElement.remove to remove element el‘s parent element.

Conclusion

To remove the parent element using plain JavaScript, we call the parentElement.remove method.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *