Closed winishahines closed 8 years ago
Did you see Nick's recommendation from a while ago? Inside an event listener function, like changeBackgroundToBlue
, the value of the variable this
is equal to the element that fired the event. For example:
<h1 id="sup">How you doin?</sup>
var h1 = document.getElementById("sup");
h1.addEventListener("click", sayHi);
function sayHi(){
alert(this.textContent);
// This would alert "How you doin?"
}
...so you can use this.style.backgroundColor
to to change the element's styling.
Worked with Maureen to fix it! Closing.
I'm trying to figure out a way to edit the code that appears on lines 56 and 59 so that a color change will happen when mousing over each individual div. I need to be able to select each div that's housed within document.body. Any suggestions?