-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
28 lines (21 loc) · 772 Bytes
/
script.js
File metadata and controls
28 lines (21 loc) · 772 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
function createTodo(todo) {
// parent element - spremamo u konstantu
const parentElement = document.querySelector('.todoContainer');
// kreirati article element s klasom todo
const article = document.createElement('article');
article.className = 'todo';
// u article upisati vrijednost
article.innerText = todo;
// appendati article parent elementu
parentElement.appendChild(article);
}
function handleSubmit(ev) {
ev.preventDefault();
const form = document.getElementById('form');
const formData = new FormData(form);
const todo = formData.get('todo');
createTodo(todo);
formData.set('todo', 72);
}
const form = document.getElementById('form');
form.addEventListener('submit', (ev) => handleSubmit(ev));