From 65b1c516134b5b7cef85f5e0589befb802f2604c Mon Sep 17 00:00:00 2001 From: Pouramua Date: Wed, 21 Sep 2016 23:42:43 +1200 Subject: [PATCH 1/2] Made second div GREEN --- events.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/events.js b/events.js index 416cdd1..24c329e 100644 --- a/events.js +++ b/events.js @@ -1,5 +1,5 @@ -// Don't change or delete this line! It waits until the DOM has loaded, then calls -// the start function. More info: +// Don't change or delete this line! It waits until the DOM has loaded, then calls +// the start function. More info: // https://developer.mozilla.org/en-US/docs/Web/Events/DOMContentLoaded document.addEventListener('DOMContentLoaded', start) @@ -7,7 +7,8 @@ function start () { // The first example is done for you. This will change the background colour of the first div // when you mouse over it. one() - + two() + // Your turn! Create a new function called `two`, then call it from here. } @@ -23,7 +24,16 @@ function one () { } // CREATE FUNCTION two HERE - +function two() { + var one = document.getElementById('two') + one.addEventListener('mouseenter', makeGreen) +function makeGreen (evt) { + evt.target.style.backgroundColor = 'green' +} + one.addEventListener('mouseleave', makeWhite)} +function makeWhite (evt) { + evt.target.style.backgroundColor = 'white' +} // CREATE FUNCTION three HERE // CREATE FUNCTION four HERE From ade7c476450c559428a3f2bad09c774c4379225d Mon Sep 17 00:00:00 2001 From: Pouramua Date: Wed, 21 Sep 2016 23:47:24 +1200 Subject: [PATCH 2/2] Finished --- events.js | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/events.js b/events.js index 24c329e..639d954 100644 --- a/events.js +++ b/events.js @@ -8,6 +8,8 @@ function start () { // when you mouse over it. one() two() + three() + four() // Your turn! Create a new function called `two`, then call it from here. } @@ -35,9 +37,27 @@ function makeWhite (evt) { evt.target.style.backgroundColor = 'white' } // CREATE FUNCTION three HERE - +function three() { + var one = document.getElementById('three') + one.addEventListener('mouseenter', makeOrange) +function makeOrange (evt) { + evt.target.style.backgroundColor = 'orange' +} + one.addEventListener('mouseleave', makeWhite)} +function makeWhite (evt) { + evt.target.style.backgroundColor = 'white' +} // CREATE FUNCTION four HERE - +function four() { + var one = document.getElementById('four') + one.addEventListener('click', makePurple) +function makePurple (evt) { + evt.target.style.backgroundColor = 'purple' +} + one.addEventListener('mouseleave', makeWhite)} +function makeWhite (evt) { + evt.target.style.backgroundColor = 'white' +} // Changes the background color of event's target function makeBlue (evt) { evt.target.style.backgroundColor = 'blue'