Find Jobs
Hire Freelancers

Event Delegation

₹600-1500 INR

Closed
Posted about 3 years ago

₹600-1500 INR

Paid on delivery
WEB230 - JavaScript 1 Assignment 6b - Event Delegation Before starting, study the HTML and open it in a browser so that you understand the structure of the document. You will add functionality to perform several tasks in our shopping list app. Clicking the red "X" at the right of an item will delete that item. Clicking on the item will style it with a strike-through to show that it has been picked up. Entering an item in the input field at the bottom will add the item if either the "+" button is clicked or the "Enter" key is pressed. Here are the steps to make this happen: Using Delegation 1. Add a click event handler to the list element (ul). This will handle events for both the removing and the marking actions. 2. Add a [login to view URL]() in the event handler to display the tagName of the target. Notice that when you click on an item in the list you get "LI" but when you click on the red "X" you get "SPAN". Clicking the item 1. Since we are using delegation, you have to determine which element was clicked on. In the ul we have both li and span elements. Use an if statement to determine if the element clicked was an li element. 2. If it was, then add the class completed to the target element. That will cause it to be displayed lighter and with a strike-through. Clicking the red "X" 1. Use another if statement to determine if the element clicked was a span element. 2. If it was, delete the li. (This is the target's parent element not the span itself). Adding a new item We want this event to happen two different ways, when the "+" button is clicked or when the "Enter" key is pressed. Therefore we will create a named function that we can use twice. 1. Add a click event handler to the a element (the plus sign) that will [login to view URL] a message. 2. Add a keydown event handler on the input element that will [login to view URL] a different message. 3. Create a named function that will add a new li element at the bottom of the list with whatever is in the input field. (Hint: input fields have a property value to get the string entered in the field. textContent does not work with inputs.) Make sure you look at the HTML file and create new li elements that look just like the ones that are there. I.E. Make sure you create a span element in it so the red "X" will appear. 4. Call this function from each of the event handlers to add the item. 5. Add code to the keydown event handler to make sure it only adds an item if the "Enter" key is pressed. (Hint: remember the [login to view URL] property?) 6. Clear the input box after creating a new list item. (Hint: input elements don't have a textContent property since they are "Empty Elements". The value property is used instead.) About Delegation Notice that you did not have to add an event handler for the new list items that you added. Because the event handler is "delegated" to the list (ul) we don't need to add event handlers when we add new items. Notes: do not modify the HTML or CSS files Include a comment in the JavaScript file with your name, student number, and the date follow best practices as discussed in the lecture video for module 4 Submission Details: Use camelCase for variable names Do not concatenate strings, use template literals Do not use the var keyword - instead use let or const Do not include any HTML tags in the JavaScript file Do not use [login to view URL] name files in lowercase with no spaces put your files in a folder and zip the folder (right click - send to --> compress folder) submit the zip file - do not use any other archive format (ie RAR, 7ZIP, etc.)
Project ID: 29858886

About the project

1 proposal
Remote project
Active 3 yrs ago

Looking to make some money?

Benefits of bidding on Freelancer

Set your budget and timeframe
Get paid for your work
Outline your proposal
It's free to sign up and bid on jobs
1 freelancer is bidding on average ₹1,500 INR for this job
User Avatar
Hi we are Grailo , let us assist you on this project we have a team of expert freelancers ready to assist you in no time. We deliver productivity with emphasis on quality . Let us know more about your requirements , ping us and let's talk
₹1,500 INR in 7 days
0.0 (0 reviews)
0.0
0.0

About the client

Flag of CANADA
Toronto, Canada
0.0
0
Member since Apr 12, 2021

Client Verification

Thanks! We’ve emailed you a link to claim your free credit.
Something went wrong while sending your email. Please try again.
Registered Users Total Jobs Posted
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Loading preview
Permission granted for Geolocation.
Your login session has expired and you have been logged out. Please log in again.