forked from fineanmol/Hacktoberfest2024
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtodolist.html
36 lines (33 loc) · 1.15 KB
/
todolist.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Todo application</title>
</head>
<body>
<input type="text"></input>
<button onclick="addtodo()">Add todo</button>
<!-- <script>
function addtodo() {
const value = document.querySelector('input').value;
const newdivel = document.createElement('div');
newdivel.innerHTML = "<div>" + value + "</div><button>Delete</button>";
document.querySelector('body').appendChild(newdivel);
}
</script> -->
<script>
function addtodo(){
const value = document.querySelector('input').value;
const spanel = document.createElement('span');
spanel.innerHTML = value;
const buttonel = document.createElement('button');
buttonel.innerHTML = 'delete';
const divel = document.createElement('div');
divel.appendChild(spanel);
divel.appendChild(buttonel);
document.querySelector('body').appendChild(divel);
}
</script>
</body>
</html>