View Code? Open in Web Editor
NEW
"To-do list" is a tool for organizing your day. It allows you to create a simple list of tasks and mark them as complete when done. This particular To-do list is built using modern technologies like ES6 and Webpack. It goes beyond just task management by incorporating functions testing with Jest, making it a comprehensive and robust project.
Home Page: https://cesarherr.github.io/To_do_List/dist/
License: MIT License
JavaScript 92.12%
CSS 7.88%
to_do_list's People
Contributors
Watchers
to_do_list's Issues
this . displayList ( ) ;
this . enterEvent ( ) ;
This lines are unnecessary
addRemoveBtnListeners ( ) {
mainList . addEventListener ( 'click' , ( event ) => {
if ( event . target . classList . contains ( 'remove-btn' ) ) {
const index = event . target . dataset . listIndex ;
this . remove ( index ) ;
}
} ) ;
mainList . addEventListener ( 'click' , ( event ) => {
if ( event . target . classList . contains ( 'fa-trash-can' ) ) {
const button = event . target . closest ( '.remove-btn' ) ;
button . click ( ) ;
}
} ) ;
}
You can work just whit the image, and your code will be shorter.
< body >
< div class ="container ">
< div class ="header ">
< h1 > Today´s To Do</ h1 >
< i class ="fa-solid fa-arrows-rotate fa-rotate-90 "> </ i >
</ div >
< label for ="text " aria-labelledby ="text "> </ label >
< input class ="add " type ="text " name ="text " placeholder ="Add to your list... ">
< ul class ="tasks ">
<!-- To do list here -->
</ ul >
< button class ="clear "> Clear all completed</ button >
</ div >
</ body >
Use the appropriate tags for each element, you can use 'header' and 'section' over div's.
const addToDo = document . querySelector ( '.add' ) ;
document . addEventListener ( 'keyup' , ( event ) => {
const activity = document . querySelector ( '.add' ) . value ;
if ( event . code === 'Enter' ) {
if ( activity !== '' ) {
toDoList . add ( activity ) ;
toDoList . displayList ( ) ;
addToDo . value = '' ;
}
Don't create new variables if you don't plan to save values, you can try: document.querySelector('.add').value = ""
const taskDescription = document . querySelectorAll ( '.taskElement' ) ;
taskDescription [ index ] . classList . toggle ( 'line-through' ) ;