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

Solutions on MaxInterview for how to change the backgroung of one button when click the other one by the best coders in the world

showing results for - "how to change the backgroung of one button when click the other one"
Fraser
28 Sep 2016
1 var buttons = document.querySelectorAll("button");
2 
3 for (button in buttons) {
4    buttons[button].onclick = function() {
5        console.log('test')
6        buttons.forEach(function(btn){
7          btn.classList.remove('highlight');
8        })
9        this.classList.add('highlight');
10    }
11}
similar questions