so when i click on the tag of the home class, i want it to change
color to green but it doesn\'t work and idk why. the click registers fine
(as the co
.style is actually a js object with keys corresponding to css properties.
As Adarsh said
document.getElementsByClassName("home")[0].style.backgroundColor = "green"
Edit - Don't do this. As Scott Marcus explains, this is pretty bad. Definitely should use querySelector('.home') to get the element.
Generally, if a property has a hyphen like background-color, you convert it to camel case ie backroundColor
Check out MDN - HTMLElement.style