function removeNode(obj) { let p; if (obj == null) return; if ((p = obj.parentNode) == null) return; p.removeChild(obj); } function exampleUse() { const obj = document.getElementById('that_thing'); removeNode(obj); }
Programming Tips - javaScript: How do I remove/delete a node from the DOM using javaScript?
Date: 2010feb16
Language: javaScript
Platform: web
Q. javaScript: How do I remove/delete a node from the DOM using javaScript?
A. Here's a function that does that: