The bulletproof wayAssuming we have the following HTML element:
var elem = document.getElementById("myDiv"); elem.parentNode.removeChild(elem);
The new way. FTW.Having already defined the variable elem, here’s how to properly remove that node:
var elem = document.getElementById("myDiv"); elem.remove();
Notice the jQuery similarity? This new way is simpler and much more intuitive... for the win.
Browser supportAt this time, the support is: Chrome, Opera, Safari and soon Firefox 23. Maybe it's not so awesome for production purposes, but still great for testing and debugging.
However, if you're looking for a larger browser support, there are some polyfills that definitely worth an eye on: