Question

In this problem, you will create a selectable “To Do” List. To add a task to this list, the user clicks the Add Task button and enters a description of the task. To delete a task from the list, the user selects the task and then clicks the Delete Task button.

  • Open the HTML and JavaScript files provided as start-up files (index.html from within todo_list_Q.zip file). Then, review the HTML in this file. Note, within the div element, there is an un-ordered list with an id of “todo” that represents a group of selectable tasks, and each task is a list item element with a class of “ui-state-default”. Also, notice how the ui-selected class is defined in the style element.
  • Add jQuery code that enables the selectable interaction on the to do list.
  • Add jQuery code that responds to the click event of the Add Task button. When this button is clicked, use the prompt method to get a description of the task. If a description is entered and the OK button is clicked, add the task before the other tasks in the list. To do that, you’ll need to add an li element with contents like the <li> elements for the other tasks. You’ll also need to enable the selectable interaction on the list again so the new task is selectable.
  • Add jQuery code that responds to the click event of the Delete Task button. When this button is clicked, each selected task should be deleted from the list.

To Do List Click the Add button to add a task Select a task and click the Delete button to remove it Wash car Prune bushes Cl

index.html

<!DOCTYPE html>
<html lang="en">
<head>
   <meta charset="UTF-8">
   <title>Selectable Interactions</title>
<!-- jQuery UI style sheet reference. Smoothness is the theme used. -->
<link href="css/smoothness/jquery-ui-1.8.23.custom.css" type="text/css" rel="stylesheet">
   <!-- Normal style sheet used for layout and general formatting. -->
<link href="styles.css" type="text/css" rel="stylesheet">
<!-- HTML5 shim/shiv for HTML5 section element backward compatibility. -->
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<!-- jQuery library reference. Latest is always referenced from jQuery's CDN. -->
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.3.min.js"></script>
<!-- jQuery UI JavaScript library reference. -->
<script type="text/javascript" src="js/jquery-ui-1.8.23.custom.min.js"></script>
<!-- jQuery call to the datepicker() method. -->
   <style>
.ui-selected {
           border: 2px solid blue;
       }
</style>
<script>
$(document).ready(function() {
   
});
</script>
</head>
  
<body>
   <section>
       <h2>To Do List</h2>
       <div>
       <h3>Click the Add button to add a task</h3>          
       <h3>Select a task and click the Delete button to remove it</h3>
       <ul id="todo">
           <li class="ui-state-default">Wash car</li>
       <li class="ui-state-default">Prune bushes</li>
       <li class="ui-state-default">Clean garage</li>          
       </ul>
       <input type="button" id="add" value="Add Task">
       <input type="button" id="delete" value="Delete Task">
</div>
   </section>
</body>
</html>

0 0
Add a comment Improve this question Transcribed image text
Answer #1

<!--index.html-->

<!DOCTYPE html>

<html lang="en">

<head>

   <meta charset="UTF-8">

   <title>Selectable Interactions</title>

<!-- jQuery UI style sheet reference. Smoothness is the theme used. -->

<link href="css/smoothness/jquery-ui-1.8.23.custom.css" type="text/css" rel="stylesheet">

   <!-- Normal style sheet used for layout and general formatting. -->

<link href="styles.css" type="text/css" rel="stylesheet">

<!-- HTML5 shim/shiv for HTML5 section element backward compatibility. -->

<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>

<!-- jQuery library reference. Latest is always referenced from jQuery's CDN. -->

<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.3.min.js"></script>

<!-- jQuery UI JavaScript library reference. -->

<script type="text/javascript" src="js/jquery-ui-1.8.23.custom.min.js"></script>

<!-- jQuery call to the datepicker() method. -->

   <style>

        .ui-selected {

           border: 2px solid blue;

        }

        

</style>

<script>

$(document).ready(function() {

    

    var list = document.querySelector('ul');

    list.addEventListener('click', function(ev) {

    if (ev.target.tagName === 'LI') {

        ev.target.classList.toggle('ui-selected');

    }

    });


    document.getElementById("add").addEventListener('click', function(ev) {

        var todo = document.getElementById("todo");

        var desc;

        desc = prompt("Enter Description: ");

        var li = document.createElement("li");

        li.className = "ui-state-default";

        var t = document.createTextNode(desc);

        li.appendChild(t);

        todo.insertBefore(li, todo.firstChild);

        desc = "";

    });

    document.getElementById("delete").addEventListener('click', function(ev) {

        var myNodelist = document.getElementsByTagName("LI");

        var arr = [], k=0;

        for (var i = 0; i < myNodelist.length; i++) {

            if(myNodelist[i].className == "ui-state-default ui-selected") {

                

                arr[k] = i;

                k++;

            }

        }

        for (var i = arr.length -1; i >= 0; i--) {

            myNodelist[arr[i]].remove();

        }

        

    });

});

</script>

</head>

   

<body>

   <section>

       <h2>To Do List</h2>

       <div>

       <h3>Click the Add button to add a task</h3>           

       <h3>Select a task and click the Delete button to remove it</h3>

       <ul id="todo">

           <li class="ui-state-default ui-selected">Wash car</li>

       <li class="ui-state-default">Prune bushes</li>

       <li class="ui-state-default">Clean garage</li>          

       </ul>

       <input type="button" id="add" value="Add Task">

       <input type="button" id="delete" value="Delete Task">

</div>

   </section>

</body>

</html>

Add a comment
Know the answer?
Add Answer to:
In this problem, you will create a selectable “To Do” List. To add a task to...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • URGENT HELP NEEDED: JQuery. PLEASE POST SCREEN SHOTS Task 1: Downloading jQuery Right-click the link to...

    URGENT HELP NEEDED: JQuery. PLEASE POST SCREEN SHOTS Task 1: Downloading jQuery Right-click the link to download the uncompressed latest version of jQuery Copy the jQuery.x.x.x.js file in the folder and specified as source file. Task 2: Download and install HTML-Kit 1. Navigate to htmlkit.com. 2. Click Download HTML-Kit 292. After it downloads, launch HKSetup.exe. Choose Full installation (the default) Uncheck Yes, download and install HTML-Kit Tools Trial. 6. Click Next>Finish. Task 3: Creating a Simple jQuery Application Launch HTML-Kit....

  • Task 3: Creating a Simple jQuery Application 1. Launch HTML-Kit. 2. Create a new HTML file...

    Task 3: Creating a Simple jQuery Application 1. Launch HTML-Kit. 2. Create a new HTML file and save it as nnLab8.htm. 3. Add the following HTML to the file: <!DOCTYPE HTML> <html> <head> <title>Hello World - jQuery Style</title> </head> <body> <div id="first"></div> <div id="second"></div> <a href="#" id="link">Click Me!</a><br /> <span id="greeting"></span> </body> </html> 4. Add the following<script> element to the<head> section. NOTE: Use the jQuery version number that matches the file name of the file you downloaded in Step 1....

  • To do list - Javascript Javascript(only)  needs to be added in order to do the following:...

    To do list - Javascript Javascript(only)  needs to be added in order to do the following: Add a new todo item to the list, complete with trash icon Remove the item when the trash icon is clicked Clear the input when the user clicks back into it to add another item. This is already in place in the JS window: (codepen)     (function(){     })(); HTML: <div class="card">     <div class="card-body">         <h3 class="card-title">Today's To Do List</h3>         <form id="todo-form">             <div class="form-group">                 <input type="text" class="form-control"...

  • Modify an application that lets users add tasks to a list so the tasks can also...

    Modify an application that lets users add tasks to a list so the tasks can also be deleted when they’re completed. 1. In the HTML file, enclose the text for each of the three existing list items in a <p> element. Then, Add buttons like the ones shown above preceding the <p> elements. No ids or names are required for these buttons, but they should be assigned to the class named “delete”. 2. In the JavaScript file, modify the event...

  • NEED HELP DIRECTIONS: Notice that there is one input area and two buttons There is a...

    NEED HELP DIRECTIONS: Notice that there is one input area and two buttons There is a place in the HTML reserved for < li > elements under the heading “Shopping List” Write a javascript program that will cause whatever the user inputs to be placed in a newly -created < li > tag and the tag placed inside the < ul > element whenever the user clicks the button Your program must not create any < li > tag is...

  • Hello Ive been tryting to add the CDN of jquery to my html code and I...

    Hello Ive been tryting to add the CDN of jquery to my html code and I keep getting an error Need help with this : ​​ Navigate to www.code.jquery.com in your Chrome browser. On this page, you'll find different stable versions of jQuery. Select uncompressed for jQuery Core 3.3.1. Copy the <script> tag that is given to you. In store_hours.html, paste that tag directly above your body's closing tag. This is the jQuery CDN. After you paste this code into...

  • Please edit and add all the code needed to make the images side by side and to put the buttons in...

    Please edit and add all the code needed to make the images side by side and to put the buttons in the middle of the images. Thank you index.html <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8">    <meta http-equiv="X-UA-Compatible" content="IE=edge">    <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Untitled Document</title> <!-- Bootstrap -->    <link href="css/bootstrap-4.0.0.css" rel="stylesheet">    <link href="style.css" rel="stylesheet" type="text/css">    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"> </head> <body> <header>    <nav class="navbar navbar-expand-lg navbar-light bg-light"> <a class="navbar-brand" href="#">Lakeside Resort Spot</a>        <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent1" aria-controls="navbarSupportedContent1" aria-expanded="false" aria-label="Toggle navigation">...

  • I'm having trouble to link the .js file to the html so changes for the html...

    I'm having trouble to link the .js file to the html so changes for the html to be made in the .js file <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width"> <title>:JavaScript, HTML and jQuery</title> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> <!-- this is so I don't have to give you a separate CSS file --> <style>     .hidden {display: none;}     .menu { width: 100px;} </style> </head> <body> <div class="container"> <h1>Assignment 2: JavaScript, HTML and jQuery</h1> <p>To complete this...

  • for Javascript, JQuery When the page is first opened a user will see the name field...

    for Javascript, JQuery When the page is first opened a user will see the name field and the three vacation images to the left of the page. The page should behave according to the following rules. 1. When a user's mouse pointer goes over any image, that image's border will change to be "outset 10px" and when the mouse pointer leaves that image it's border will change to "none". 2. When the user clicks a "Vacation" image on the left,...

  • <!DOCTYPE html> <html> <head> <!-- JavaScript 6th Edition Chapter 4 Hands-on Project 4-3 Author: Da...

    <!DOCTYPE html> <html> <head> <!-- JavaScript 6th Edition Chapter 4 Hands-on Project 4-3 Author: Date:    Filename: index.htm --> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>Hands-on Project 4-3</title> <link rel="stylesheet" href="styles.css" /> <script src="modernizr.custom.05819.js"></script> </head> <body> <header> <h1> Hands-on Project 4-3 </h1> </header> <article> <div id="results"> <p id="resultsExpl"></p> <ul> <li id="item1"></li> <li id="item2"></li> <li id="item3"></li> <li id="item4"></li> <li id="item5"></li> </ul> </div> <form> <fieldset> <label for="placeBox" id="placeLabel"> Type the name of a place, then click Submit: </label> <input type="text" id="placeBox"...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT