-
Notifications
You must be signed in to change notification settings - Fork 0
/
shoppinglist.js
43 lines (38 loc) · 1 KB
/
shoppinglist.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
/**
*
* @authors Your Name (you@example.org)
* @date 2018-05-30 20:55:59
* @version $Id$
*/
//check off specific todos by clicking
$("ul").on("click", "li" , function(){
/* if($(this).css("color") === "rgb(128, 128, 128)"){
$(this).css("color", "rgb(0,0,0)");
$(this).css("text-decoration", "NONE");
}
else{
$(this).css("color", "gray");
$(this).css("text-decoration", "line-through");
} */
$(this).toggleClass("completed");
})
$("ul").on("click", "span", function(){
$(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("");
//creat a new li and add to ul
$("ul").append("<li><span><i class='fa fa-trash'></i></span>" + todoText + "</li>");
console.log($("input[type='text']").val());
$("#inp").val("");
}
});
$(".fa-plus").click(function(){
$("input[type='text'").fadeToggle();
})