Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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');
    }
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #change #backgroung #button #click
ADD COMMENT
Topic
Name
3+9 =