forked from gSchool/stoplight-event-exercise
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
58 lines (39 loc) · 1.49 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
let stopButton = document.getElementById("stopButton");
let stopLight = document.getElementById("stopLight");
let slowButton = document.getElementById("slowButton");
let slowLight = document.getElementById("slowLight");
let goButton = document.getElementById("goButton");
let goLight = document.getElementById("goLight");
let count = 0;
stopButton.addEventListener("click", function (){
stopLight.classList.toggle("stop");
})
slowButton.addEventListener("click", function (){
slowLight.classList.toggle("slow");
})
goButton.addEventListener("click", function (){
goLight.classList.toggle("go");
})
// mouse movent listeners
function handlemouseEntered(event){
console.log(`entered ${event.target.textcontent} button`);
}
function handlemouseLeft(event) {
console.log(`left ${event.target.textcontent} button`)
}
stopButton.addEventListener('mouseenter', handlemouseEntered);
slowButton.addEventListener('mouseenter', handlemouseEntered);
goButton.addEventListener('mouseenter', handlemouseEntered);
stopButton.addEventListener('mouseenter', handlemouseLeft);
slowButton.addEventListener('mouseenter', handlemouseLeft);
goButton.addEventListener('mouseenter', handlemouseLeft);
function handleBulbOn(event) {
console.log(`${event.target.textcontent} bulb on`)
}
goButton.addEventListener('click', handleBulbOn);
// function handlemouseEntered(event){
// console.log(`entered ${event.target.textcontent} button`);
// (function() {
// 'use strict';
// // YOUR CODE HERE
// })();