Build one of the most common applications on the web, a simple todo application, with HTML, CSS, and JavaScript.
-
Fork and clone this repository.
-
Navigate to the
settingstab on GitHub, then choosePagesfrom the menu. Configure theBuild and Deploymentto have aSourceofDeploy from a branchand select themainbranch for deployment. Deployments can take a few minutes, so get started on the lab, and then be sure to check the deployment after you have made a few commits. -
Open up the repository in VSCode. Follow the instructions below to complete the Lab.
The app will have the following items:
- An
h1title (e.g. "My To-Dos"). - A single
ultag, empty when the page is first loaded. - A
formfor the user to add a new to-do, with a single textinputand asubmitbutton.
And the following functionalities:
-
When the user writes something in the
form's text input area and clickssubmit, theulshould update with a newliitem at the bottom of the list. The page should not refresh.Hints/Steps
- Add an event listener to the form with
.addEventListener. What event do you want to listen for? - Remember, what does
event.preventDefault()do? - Grab the value the user typed from the text input. Do you remember what property of the input node has this? If not Google it or ask a peer.
- Create new
lielement withdocument.createElement(). Set itstextContentproperty to be the text the user typed. - Don't forget to append the created
lito the list.
- Add an event listener to the form with
-
When the user writes nothing in the
form's text input area and clickssubmit, an error message (inside aptag) should appear below the form.Hints/Steps
- How can you check if the input text has something typed or not?
- Have an empty paragraph that is above the
<ul>and under the<form>. If the user didn't type anything, modify the content of the paragraph to display a text like: 'Error. Todo cannot be empty'
-
When the user clicks on one of the
liitems, the item should be crossed out, indicating that that to-do is complete. You will need to look at[element].style.textDecorationfor the cross out effect. Look at all the different text decoration options.Hints/Steps
- You will need to add an event listener to all the
lielements. Thoselielements have yet to be created. How can you add an event listener to these? - How can you only affect the
lithat was clicked on?
- You will need to add an event listener to all the
- Have the input go back to empty after adding a new todo.
- Implement a delete
buttonnext to eachlithat removes thatlitag entirely. - Clicking a todo that is crossed out (completed) uncrosses the todo.
- Add the ability to add multiple to-dos if the user submits a text input with multiple lines. Each line should be a new to-do.
- Add some CSS styling to your app.
