i don't want to use this method because if there's multiple elements with same id they will all be removed i need a method to only delete the parent element of the button that was clicked. Because if you execute this code and click the button it will delete all elements with the id of "div-list" but i only want it to delete the parent element of only the button that clicked it
let button = document.getElementById('button-submit');
let div = document.getElementById('div-list');
div.appendChild(button);
button.onclick = () => {
div.remove();
}
i found a way that works but i want another one that is only javascript here's the method that works but i hope there's another way to do it:
<div>
<button onclick="this.parentElement.remove()"></button>
<div>