Skip to content

hihi-2017/event-handling

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

// 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)

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. }

function one () { // First, we have to find the element: var one = document.getElementById('one')

// Next, we add an event listener to it: one.addEventListener('mouseenter', makeBlue)

// Finally, we add one to make the colour white again one.addEventListener('mouseleave', makeWhite) }

// CREATE FUNCTION two HERE function two () { var two = document.getElementById('two') two.addEventListener('mouseenter', makeGreen)

two.addEventListener('mouseleave', makeWhite) } // CREATE FUNCTION three HERE

// CREATE FUNCTION four HERE

// Changes the background color of event's target function makeBlue (evt) { evt.target.style.backgroundColor = 'blue' evt.target.style.backgroundColor = 'green' }

function makeWhite (evt) { evt.target.style.backgroundColor = 'white' }

About

Simple event handling

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • JavaScript 79.9%
  • HTML 11.5%
  • CSS 8.6%