File tree 1 file changed +27
-0
lines changed
Source-Code/ToDoList/module
1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change
1
+ export function addTask ( taskInput , categorySelect , taskList ) {
2
+ const taskText = taskInput . value . trim ( ) ;
3
+ const category = categorySelect . value ;
4
+
5
+ if ( taskText === '' || category === '' ) {
6
+ alert ( 'Please enter a task and select a category.' ) ;
7
+ return ;
8
+ }
9
+
10
+ const li = document . createElement ( 'li' ) ;
11
+ li . classList . add ( 'task-item' ) ;
12
+ li . innerHTML = `
13
+ <span class="task-text">${ taskText } (${ category } )</span>
14
+ <button class="delete-btn">Delete</button>
15
+ ` ;
16
+
17
+ taskList . appendChild ( li ) ;
18
+
19
+ // Clear input fields
20
+ taskInput . value = '' ;
21
+ categorySelect . value = '' ;
22
+ }
23
+
24
+ export function deleteTask ( button ) {
25
+ const taskList = document . getElementById ( 'task-list' ) ;
26
+ taskList . removeChild ( button . parentElement ) ;
27
+ }
You can’t perform that action at this time.
0 commit comments