JavaScript Really quick way to remove an element from the DOM

This is arguable the simplest and most cross-browser friendly way to remove an element from the DOM. Essentially, we're just setting the elements outer HTML to an empty string, which removes the element.
document.getElementById('the_element_id').outerHTML = '';
Posted by
Snippet Viewed 1644 times.

Share your JavaScript code snippets:

  • Get some recognition & link back to your site.


Submit | Browse

Most Recent javascript snippets

Most Viewed