Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

214
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!