I am new to javascript and trying to write a javascript code so when a button is clicked its colour will change. I tried different ways but when clicked on the first element works. Not really sure what is going on here. I would appreciate any help.
var count = 1;
        function setColor(button, color) {
          var property = document.getElementsByClassName("button");
          if (count == 0) {
            property.style.backgroundColor = "#A94E3B"
            count = 1;
          }
          else {
            property.style.backgroundColor = "#EAE8E8"
            count = 0;
          }
        }
 
     
    