File tree Expand file tree Collapse file tree 1 file changed +28
-1
lines changed
Expand file tree Collapse file tree 1 file changed +28
-1
lines changed Original file line number Diff line number Diff line change 1- // ToDo App Logic
1+ const taskInput = document . querySelector ( "#taskInput" ) ;
2+ const taskAddBtn = document . querySelector ( "#addSvg" ) ;
3+ const taskContainer = document . querySelector ( ".task-container" ) ;
4+ const taskField = document . querySelector ( ".task" ) ;
5+ const clearAllTaskBtn = document . querySelector ( "#clearAllTaskBtn" ) ;
6+
7+ // add the task when click
8+ taskAddBtn . addEventListener ( "click" , ( ) => {
9+ // get input field value
10+ const newTask = taskInput . value ;
11+
12+ if ( newTask !== '' && newTask . length >= 5 )
13+ {
14+ // cloning the structure of tasks
15+ const newTaskField = taskField . cloneNode ( true ) ;
16+
17+ // select the task text field
18+ const newTaskText = newTaskField . querySelector ( ".taskText" ) ;
19+ newTaskText . textContent = newTask ;
20+
21+ taskContainer . append ( newTaskField ) ;
22+
23+ taskInput . value = '' ;
24+ }
25+ else
26+ alert ( "Task must be of at least 5 characters to be registered." ) ;
27+
28+ } ) ;
You can’t perform that action at this time.
0 commit comments