ga-wdi-exercises / project1

[project] GA- Project 1
3 stars 75 forks source link

issue with mouseover functionality #238

Closed winishahines closed 8 years ago

winishahines commented 8 years ago

snip20160224_2

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?

RobertAKARobin commented 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.

winishahines commented 8 years ago

Worked with Maureen to fix it! Closing.