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 559 times.

Share your JavaScript code snippets:

  • Get some recognition & a link back to your site.
  • Create your own code library.
  • Help your fellow developers, as they have helped you.
Submit | Browse

Most Recent javascript snippets

Most Viewed

The FitDesk Under Desk Elliptical