When I try to remove element by clicking them. I suffered some trouble.
When I create element and append this to element,previous element was not removed.
My desired result is to replace them to new button.
How can I achieve it? If you have opinion,please let me know.
thanks
document.getElementById("btn").addEventListener("click",function(){
let btn = document.getElementById("btn");
let button = document.createElement("button");
button.textContent = 'retry';
button.className = 'retry';
btn.appendChild(button);
})
<div id="btn"><button>test</button></div>