javascript remove parent code example

Example 1: how to remove an element from a parent element javascript

function removeElement(el) {
    el.parentNode.removeChild(el);
}

// or
HTMLElement.prototype.remove = function() { this.parentNode.removeChild(this); return this; }

Example 2: remove parent element javascript

node.parentNode.parentNode.removeChild(node.parentNode)

Example 3: delete parent js

parentElemnet.appendChild(childElemnet);
childElemnet.appendChild(buttonRemoveElement)
buttonRemoveElement.onclick = () => {perentElement.remove(childElement)}