-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
26 lines (24 loc) · 839 Bytes
/
script.js
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
let todoList = [];
let todoDate = [];
function addTodo(){
let inputElement = document.querySelector('#task-input');
let todoItem = inputElement.value;
todoList.push(todoItem);
inputElement.value = '';
let inputDate = document.querySelector('#todo-date');
let date = inputDate.value;
todoDate.push(date);
inputDate.value = '';
displayItems();
}
function displayItems(){
let containerElement = document.querySelector('.todo-container');
let newhtml = '';
for(let i=0;i<todoList.length; i++){
newhtml += `<span>${todoList[i]}</span>
<span>${todoDate[i]}</span>
<button id="del" onclick="todoList.splice(${i}, 1);
displayItems();"> Delete </button>`;
}
containerElement.innerHTML = newhtml;
}