From 9164859b274e5c42009015d93110bde1a488d3db Mon Sep 17 00:00:00 2001 From: Matthew Gonzer Date: Tue, 2 May 2017 15:42:06 -0600 Subject: [PATCH] add stoplight exercise --- index.css | 2 +- index.js | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 1 deletion(-) diff --git a/index.css b/index.css index fabc52b..a8c51ed 100644 --- a/index.css +++ b/index.css @@ -32,7 +32,7 @@ body { border-radius: 50%; margin: 25px auto; height: 150px; - transition: background 300ms; + /*transition: background 300ms;*/ width: 150px; } diff --git a/index.js b/index.js index 03cc920..fb7888d 100644 --- a/index.js +++ b/index.js @@ -2,4 +2,63 @@ 'use strict'; // YOUR CODE HERE + var stopBtn = document.getElementById('stopButton'); + var stopLte = document.getElementById('stopLight'); + stopBtn.addEventListener('click', activateStop); + stopBtn.addEventListener('mouseenter', enter); + stopBtn.addEventListener('mouseleave', leave); + function enter(){ + console.log("Entered " + this.textContent + " button"); + } + function leave(){ + console.log("Left " + this.textContent + " button"); + } + function activateStop(){ + if (stopLte.style.background == "red"){ + stopLte.style.background = "black"; + } else {stop + stopLte.style.background = "red"; + } + } + + + var slowBtn = document.getElementById('slowButton'); + var slowLte = document.getElementById('slowLight'); + slowBtn.addEventListener('click', activateSlow); + slowBtn.addEventListener('mouseenter', enter); + slowBtn.addEventListener('mouseleave', leave); + function enter(){ + console.log("Entered " + this.textContent + " button"); + } + function leave(){ + console.log("Left " + this.textContent + " button"); + } + function activateSlow(){ + if (slowLte.style.background == "orange"){ + slowLte.style.background = "black"; + } else { + slowLte.style.background = "orange"; + } + } + + + var goBtn = document.getElementById('goButton'); + var goLte = document.getElementById('goLight'); + goBtn.addEventListener('click', activateGo); + goBtn.addEventListener('mouseenter', enter); + goBtn.addEventListener('mouseleave', leave); + + function enter(){ + console.log("Entered " + this.textContent + " button"); + } + function leave(){ + console.log("Left " + this.textContent + " button"); + } + function activateGo(){ + if (goLte.style.background == "green"){ + goLte.style.background = "black"; + } else { + goLte.style.background = "green"; + } + } })();