Element.parentNode
to get the given element's parent node.Element.removeChild()
to remove the given element from its parent node.const removeElement = el => el.parentNode.removeChild(el);
removeElement(document.querySelector('#my-element')); // Removes #my-element from the DOM
Subscribe to get resources directly to your inbox. You won't receive any spam! ✌️