Giter Club home page Giter Club logo

event_listener_lesson's Introduction

Event Listeners!

Objectives

  1. Define the 'parts' of an event listener.
  2. Describe the event and properties of the event.
  3. Demonstrate using an event listener with 'click' and 'submit'.

Warm-up

Take a minute to research on your own, what is a web event? Be prepared to share some events examples.

What is happening when an event listener is called?

What is the event target?

How do we add an event listener to an element?

Let's play with this.

  1. Copy the following HTML into a new HTML document.
<div>
  <ul>
    <li>
      <text>Meow</text>
      <button>Delete</button>
    </li>
  </ul>
</div>
  1. Attach a JavaScript file.
  2. Work with a buddy to add two event listeners, one that when we click the Meow, it meow's. The other should remove the element when someone clicks on Delete.

Let's have a Hedgehog Party!

  1. Clone this repo (note you have a frontend and backend folder inside.)
  2. cd into Hedgehog party.
  3. cd into backend
  4. run bundle and rails db:create, rails db:migrate, and rails db:seed
  5. run rails s
  6. In terminal, type cd ../frontend

This is where you'll be working. You can start this off with lite-server

Your tasks:

  1. As a user, when I fill in the form to create a new Hedgehog RSVP and click submit, I see that new Hog on my Party Goers list.
  2. When I click one of the age range buttons, I should only see the hogs that match that age range.
  3. As a user, when I click the Cancel RSVP button next to a Hedgehog, it removes that hog from the RSVP list (Note: this won't delete it from the API so on refresh, that hog will return.)

If there's time: What if I wanted to grab all the delete buttons after they were created and add an event listener to each of them? Event delegation.

event_listener_lesson's People

Contributors

kathleenscriver avatar

Watchers

James Cloos 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.