-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
31 lines (24 loc) · 756 Bytes
/
script.js
File metadata and controls
31 lines (24 loc) · 756 Bytes
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
var removebtn = $("#remove");
var completed = $("#complete");
var additem = function() {
var userinput = $("#input").val();
$("#todolist").append("<li class='task'>" + userinput + "<span id='remove'> X</span><span id='complete'> <input id='box1' type='checkbox' /></span></li>");
$("#input").val("");
}
var cross = function() {
alert("You pressed an item");
}
$("#input").keypress(function(e) {
if(e.which == 13) {
additem();
}
});
$("ul").on("click", "span#remove", function(event){
$(this).parent().fadeOut(500, function() {
$(this).remove();
})
event.stopPropagation();
})
$("ul").on("click", "span#complete", function(event) {
$(this).parent().toggleClass( "completed" )
});