Sometimes, we want to remove a child node in HTML using JavaScript.
In this article, we’ll look at how to remove a child node in HTML using JavaScript.
How to remove a child node in HTML using JavaScript?
To remove a child node in HTML using JavaScript, we can use the remove
method.
For instance, we write
document.getElementById("FirstDiv").remove();
to select the element with getElementById
.
Then we call remove
to remove the selected element.
Conclusion
To remove a child node in HTML using JavaScript, we can use the remove
method.