-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtodos.js
45 lines (40 loc) · 1.09 KB
/
todos.js
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
//check off specific todos by clicking
//if li is gray
// if($(this).css("color") === "rgb(128, 128, 128)")
// {
// //turn it black
// $(this).css({
// color: "black",
// textDecoration: "none"
// });
// }
// //else
// else{
// $(this).css({
// color: "gray",
// textDecoration: "line-through"
// });
// }
// Check Off Specific Todos By Clicking
$("ul").on("click", "li", function(){
$(this).toggleClass("completed");
});
//Click on X to delete Todo
$("ul").on("click", "span", function(event){
$(this).parent().fadeOut(500,function(){
$(this).remove();
});
event.stopPropagation();
});
$("input[type='text']").keypress(function(event){
if(event.which === 13){
//grabbing new todo text from input
var todoText = $(this).val();
$(this).val("");
//create a new li and add to ul
$("ul").append("<li><span><i class='fa fa-trash'></i></span> " + todoText + "</li>")
}
});
$(".fa-plus").click(function(){
$("input[type='text']").fadeToggle();
});