Find Jobs
Hire Freelancers

Event Delegation

₹600-1500 INR

已关闭
已发布大约 3 年前

₹600-1500 INR

货到付款
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.)
项目 ID: 29858886

关于此项目

1条提案
远程项目
活跃3 年前

想赚点钱吗?

在Freelancer上竞价的好处

设定您的预算和时间范围
为您的工作获得报酬
简要概述您的提案
免费注册和竞标工作
1威客以均价₹1,500 INR来参与此工作竞标
用户头像
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 在7天之内
0.0 (0条评论)
0.0
0.0

关于客户

CANADA的国旗
Toronto, Canada
0.0
0
会员自4月 12, 2021起

客户认证

谢谢!我们已通过电子邮件向您发送了索取免费积分的链接。
发送电子邮件时出现问题。请再试一次。
已注册用户 发布工作总数
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
加载预览
授予地理位置权限。
您的登录会话已过期而且您已经登出,请再次登录。