Implement solution.
This commit is contained in:
parent
9f424e9ebb
commit
f57da84b34
26
index.js
26
index.js
@ -1,5 +1,23 @@
|
|||||||
(function() {
|
document.addEventListener("DOMContentLoaded",()=>{
|
||||||
'use strict';
|
document.getElementById("controls").addEventListener("click",(clicked)=>{
|
||||||
|
var lightPrefix = clicked.target.id.replace("Button","");
|
||||||
|
var targetLight = document.getElementById(lightPrefix+"Light");
|
||||||
|
if (!targetLight.classList.contains(lightPrefix)) {
|
||||||
|
targetLight.classList.add(lightPrefix);
|
||||||
|
console.log(lightPrefix+" bulb on.")
|
||||||
|
} else {
|
||||||
|
targetLight.classList.remove(lightPrefix);
|
||||||
|
console.log(lightPrefix+" bulb off.")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
// YOUR CODE HERE
|
var buttons = document.getElementsByClassName("button");
|
||||||
})();
|
for (var i=0;i<buttons.length;i++) {
|
||||||
|
buttons[i].addEventListener("mouseenter",(e)=>{
|
||||||
|
console.log("Entered "+e.target.innerHTML+" button.")
|
||||||
|
})
|
||||||
|
buttons[i].addEventListener("mouseleave",(e)=>{
|
||||||
|
console.log("Left "+e.target.innerHTML+" button.")
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
Loading…
x
Reference in New Issue
Block a user