GithubHelp home page GithubHelp logo

isabellatea / funwithdomevents Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 26.0 113 KB

Practice implementing DOM Events using vanilla Javascript

HTML 41.79% CSS 58.21%
beginner-project dom-manipulation javascript javascript-practice

funwithdomevents's Introduction

FunWithDOMEvents

  • Level: Beginner
  • Description: Practice implementing DOM events using vanilla Javascript

Lesson

To implement DOM events, use the process flow:

  1. Identify the element you are watching/targetting
  2. Set an event listener on it with what is being listening for and reference the function that should be invoked when the even occurs
  3. Write a function with all of the things that should happen once the event is triggered

Challenges

  • Challenge Zero: Make the “play” button move to random locations as you click it
  • Challenge One: When you double-click a piece of text, make the text “disappear”
  • Challenge Two: When you mouseover the button, the background color of it changes
  • Challenge Three: When you copy (command + c) the title “Gotta catch em all,” an alert appears warning you not to
  • Challenge Four: When you right click on any element in the body, the background changes to a different image

Example

let playButton = document.getElementById("play-button");
playButton.addEventListener("click", myEventHandler);

function myEventHandler() {
  alert ("Hello World!");
}

Relevant DOM Events

  • click → “click”
  • double click → “dblclick”
  • mouse over → “mouseover”
  • copy → “copy”
  • right click → “contextmenu”

Solution Gist

script.js

funwithdomevents's People

Contributors

isabellatea avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.