What I want to do is so that when I click the yes button, all the items are removed, and when I click the reset button, everything goes back, and so many times. What I get: I press the "yes" button, everything is deleted, then the "reset" button, everything goes back, I want to press the "yes" button again, but nothing else works
const body = document.querySelector('.body');
const message = document.querySelector('.message');
const reset = document.querySelector('.panel__close')
const bodyMessage = document.querySelector('.body__message')
function removeChilds(childs) {
for(const child of childs){
child.parentNode.removeChild(child);
}
}
let childs = [];
function create() {
// here created elements for programm...
childs.push(bodyError, bodyErrorImage, bodyText, bodyButtons, bodyButton1, bodyButton); // the created elements are pushing into the array
}
create();
yes.addEventListener('click', () => { // here deleting all elements and creating congratulation
removeElements(childs);
childs = [];
// created congratulation
const paraLox = document.createElement('p');
paraLox.textContent = 'Congratulation, Jaba is work!';
paraLox.style.fontSize = '3rem';
paraLox.style.textAlign = 'center';
paraLox.style.fontWeight = '1000';
paraLox.style.color = 'red';
body.appendChild(paraLox);
//
reset.addEventListener('click', () => { // reset button
paraLox.parentNode.removeChild(paraLox);
create();
});
});