Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

219
Visualizações
how to make the button work the next time the button is pressed

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();
    
    
    });


});
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda