-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
56 lines (55 loc) · 1.89 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
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="utf-8" />
<title>Pick right tool for your frontend</title>
<meta name="description" content="You might not need react" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
</head>
<body>
<section style="border: 1px solid; padding: 10px">
<h3>HTML</h3>
<form>
<input type="checkbox" id="todo" />
<label for="todo">Buy milk</label><br />
<input type="text" placeholder="add todo" />
<button type="button">add</button>
</form>
<h4>limitation</h4>
<ul>
<li>can't add new todo</li>
<li>state is lost as soon as page is refreshed</li>
</ul>
<h4>best for</h4>
<ul>
<li>blogs</li>
<li>apps which have minimum user interactivity</li>
</ul>
</section>
<section class="border">
<link rel="stylesheet" href="style.css" type="text/css" />
<h3>HTML + JS</h3>
<form id="todo-form">
<input type="checkbox" id="todo" />
<label for="todo">Buy milk</label><br />
<input id="todo-text" type="text" placeholder="add todo" />
<button type="button" onclick="addTodo()">add</button>
</form>
<script>
const addTodo = () => {
const newTodo = document.getElementById("todo-text").value;
const newCheckboxEl = document.createElement("input");
newCheckboxEl.setAttribute("type", "checkbox");
const newLabelEl = document.createElement("label");
newLabelEl.innerText = newTodo;
document
.getElementById("todo-form")
.insertBefore(newCheckboxEl, document.getElementById("todo-text"));
document
.getElementById("todo-form")
.insertBefore(newLabelEl, document.getElementById("todo-text"));
};
</script>
</section>
</body>
</html>