remove parent element from child element in js 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: delete parent js
parentElemnet.appendChild(childElemnet);
childElemnet.appendChild(buttonRemoveElement)
buttonRemoveElement.onclick = () => {perentElement.remove(childElement)}