-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
65 lines (65 loc) · 1.82 KB
/
index.html
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<link rel="stylesheet" href="todo-list.css">
<body>
<div class="main">
<p class="todomain">Todo List</p>
<div class="input">
<input type="text" placeholder="Todo Name" class="boxtext">
<input type="date"placeholder="DD-MM-YYYY" class="dateinput">
<button class="add"
onclick="
Todo()
">Add</button>
</div>
<div class="list"></div>
</div>
<script>
let array=[]
function todofinal(){
let todohtml='';
for(let i=0;i<array.length;i++){
let todovalue=array[i];
let name=todovalue.name;
let date=todovalue.date;
let html=
`
<div>${name}</div>
<div>${date}</div>
<button class="delete "onclick="
array.splice(${i},1)
todofinal()
">
delete
</button>
`
todohtml+=html;
}
document.querySelector(".list").innerHTML=todohtml;
}
function Todo(){
let value=document.querySelector(".boxtext")
let date=document.querySelector(".dateinput")
let v1=value.value
let d1=date.value
localStorage.setItem('name1',v1);
localStorage.setItem('date1',d1);
array.push(
{
name:v1,
date:d1,
}
)
console.log(array)
value.value='';
date.value=''
todofinal();
}
</script>
</body>
</html>