|
1 | 1 | const form = document.getElementById('task-form'); |
2 | 2 | const taskList = document.getElementById('tasks'); |
3 | 3 |
|
4 | | -form.onsubmit = function (e){ |
5 | | - e.preventDefault(); |
6 | | - const inputField = document.getElementById('task-input'); |
7 | | - addTask(inputField.value); |
8 | | - form.reset(); |
| 4 | +form.onsubmit = function (e) { |
| 5 | + e.preventDefault(); |
| 6 | + const inputField = document.getElementById('task-input'); |
| 7 | + addTask(inputField.value); |
| 8 | + form.reset(); |
9 | 9 | }; |
10 | 10 |
|
11 | | -function addTask(description){ |
12 | | - const taskContainer = document.createElement('div'); |
13 | | - const newTask = document.createElement('input'); |
14 | | - const taskLabel = document.createElement('label'); |
15 | | - const taskDescriptionNode = document.createTextNode(description); |
| 11 | +function addTask(description) { |
| 12 | + const taskContainer = document.createElement('div'); |
| 13 | + const newTask = document.createElement('input'); |
| 14 | + const taskLabel = document.createElement('label'); |
| 15 | + const taskDescriptionNode = document.createTextNode(description); |
16 | 16 |
|
17 | | - newTask.setAttribute('type', 'checkbox'); |
18 | | - newTask.setAttribute('name', description); |
19 | | - newTask.setAttribute('id', description); |
| 17 | + newTask.setAttribute('type', 'checkbox'); |
| 18 | + newTask.setAttribute('name', description); |
| 19 | + newTask.setAttribute('id', description); |
20 | 20 |
|
21 | | - taskLabel.setAttribute('for', description); |
22 | | - taskLabel.appendChild(taskDescriptionNode); |
| 21 | + taskLabel.setAttribute('for', description); |
| 22 | + taskLabel.appendChild(taskDescriptionNode); |
23 | 23 |
|
24 | | - taskContainer.classList.add('task-item') |
25 | | - taskContainer.appendChild(newTask); |
26 | | - taskContainer.appendChild(taskLabel); |
| 24 | + taskContainer.classList.add('task-item'); |
| 25 | + taskContainer.appendChild(newTask); |
| 26 | + taskContainer.appendChild(taskLabel); |
27 | 27 |
|
28 | | - taskList.appendChild(taskContainer); |
| 28 | + taskList.appendChild(taskContainer); |
29 | 29 | } |
0 commit comments