Answers for "how to change the backgroung of one button when click the other one"

0

how to change the backgroung of one button when click the other one

var buttons = document.querySelectorAll("button");
 
 for (button in buttons) {
    buttons[button].onclick = function() {
        console.log('test')
        buttons.forEach(function(btn){
          btn.classList.remove('highlight');
        })
        this.classList.add('highlight');
    }
}
Posted by: Guest on August-25-2021

Code answers related to "how to change the backgroung of one button when click the other one"

Code answers related to "Javascript"

Browse Popular Code Answers by Language