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; } }
https://stackoverflow.com/questions/65366258/javascript-using-getelementbyclassname-to-change-button-colour December 19, 2020 at 10:57AM
没有评论:
发表评论