This content originally appeared on Go Make Things and was authored by Go Make Things
The Node.remove()
method lets you remove an element from the DOM. Call it on the element you want to remove.
For example, let’s say you had a heading and paragraph, like this.
<h1>Hello, world!</h1>
<p>How are you today?</p>
To remove the h1
element, you would do this.
let h1 = document.querySelector('h1');
h1.remove();
This content originally appeared on Go Make Things and was authored by Go Make Things
Go Make Things | Sciencx (2021-03-25T14:30:00+00:00) How to remove an element from the DOM with vanilla JS. Retrieved from https://www.scien.cx/2021/03/25/how-to-remove-an-element-from-the-dom-with-vanilla-js/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.