-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
49 lines (47 loc) · 1.63 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
<!DOCTYPE html>
<html>
<head>
<title>freeDOM</title>
<script type="text/javascript" src="./lib/freeDOM.js" charset="utf-8"></script>
<link rel="stylesheet" href="styles.css" />
</head>
<body>
<img class="todolist" src="./images/todolist.png"/>
<form action="index.html" method="post" class="header">
<input type="text" class="input" placeholder="Please add your todo here">
<button class="submit">Add</button>
<!-- <input type="submit" class="submit" value="Add"> -->
</form>
<ul class="todo-list"></ul>
<script type="text/javascript">
const addTodo = () => {
$l(".submit").on("click", e => {
e.preventDefault();
const value = document.querySelector('.input').value;
if (value) {
$l('.todo-list').append(
`<li class="listitem">
<span class="item">${value}</span>
<button class="delete">X</button>
</li>`);
}
document.querySelector('.input').value = "";
});
}
const removeTodo = () => {
$l(".todo-list").on("click", e => {
if ($l(e.target).attr("class") === "delete") {
$l(e.target).parent().remove();
}
});
}
addTodo();
removeTodo();
</script>
</body>
<div id="footer">
<li><a href="https://github.com/dongjinxujill/freeDOM" class="icon alt fa-github"><span class="label">GitHub</span></a></li>
<li><a href="https://www.linkedin.com/in/dongjinxu" class="icon alt fa-linkedin"><span class="label">LinkedIn</span></a></li>
<li>© 2018 Dongjin Xu</li>
</div>
</html>