-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathulProject.js
More file actions
45 lines (41 loc) · 1.3 KB
/
Copy pathulProject.js
File metadata and controls
45 lines (41 loc) · 1.3 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
const getTasksButton= document.querySelector("#get-tasks");
const createTasksButton= document.querySelector("#create-tasks");
getTasksButton.addEventListener("click",() =>{
const promise = getTasks();
promise.then(onTasksReceived);
});
createTasksButton.addEventListener("click",()=>{
createTasks('nhb').then((data) =>{
console.log(data);
});
createTasks('do math').then((data) =>{
console.log(data);
});
});
function onTasksReceived(tasks){
const result = document.querySelector("#itemsGet");
result.innerHTML="";
tasks.forEach(task => {
var li = document.createElement("li");
var inputValue = task.title;
var t = document.createTextNode(inputValue);
li.appendChild(t);
if (inputValue === '') {
alert("You must write something!");
} else {
document.getElementById("items").appendChild(li);
}
document.getElementById("myInput").value = "";
var span = document.createElement("SPAN");
var txt = document.createTextNode("\u00D7");
span.className = "close";
span.appendChild(txt);
li.appendChild(span);
for (i = 0; i < close.length; i++) {
close[i].onclick = function() {
var div = this.parentElement;
div.style.display = "none";
}
}
})
}