-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathto_do_list.html
41 lines (39 loc) · 1.09 KB
/
to_do_list.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
<!DOCTYPE html>
<html>
<head>
<title>To do list</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
</head>
<body>
<div><br/><strong>Maintain your to-do list!</strong></div>
<form>
<div>
<label for="todo">I need to:</label>
<input type="text" id="todo" />
</div>
<button id ="add" type="button">Add to your to-do list!</button>
</form>
<div><strong>To-do list (click any item to remove from list):</strong></div>
<ul>
</ul>
</body>
<script>
$(document).ready(function() {
$('#add').click(function() {
var $item = $('#todo')
$('ul').prepend("<li>"+$item.val()+"</li>");
$item.val("");
});
$('ul').on('click', 'li', function() {
$(this).remove();
});
$(document).keypress(function(e) {
if(e.which == 13) {
var $item = $('#todo')
$('ul').prepend("<li>"+$item.val()+"</li>");
$item.val("");
}
})
});
</script>
</html>