-
Notifications
You must be signed in to change notification settings - Fork 0
/
todo.html
41 lines (41 loc) · 979 Bytes
/
todo.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
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script>
$(document).ready(function() {
$('.add_todo').submit(function(event) {
$(".error").text("");
var $input = $(event.target).find("input:first");
if ($input.val() == "") {
$(".error").append("Enter something son");
} else {
$("ul").append("<li><input type='checkbox' />" + $input.val() + "</li>");
$input.val("");
}
return false;
});
});
</script>
<style>
li {
list-style: none;
}
input[type="checkbox"]{
margin-right: 10px;
}
.error {
background: red;
color: #fff;
margin: 0;
}
</style>
</head>
<body>
<form class="add_todo">
What do you need to do today? <input type="text" />
</form>
<p class="error"></p>
<ul>
</ul>
</body>
</html>