-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtodo.js
45 lines (40 loc) · 1.03 KB
/
todo.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
$("ul").on("click", "li" , function(){
$(this).toggleClass("select");
});
$("ul").on("click", "span",function(event){
$(this).parent().fadeOut(500,function(){
$(this).remove();
});
event.stopPropagation();
})
// to enter your todos
$("input[type='text'").keypress(function(event){
if(event.which === 13){
var todotext = $(this).val();
$(this).val("");
if(todotext===""){
//Alert message
swal({
title: "Ooops!",
text: "Write Something To Add!",
icon: 'info',
buttons: true,
dangerMode: true,
});
}else if(todotext.length <=40){
$("ul").append("<li><span title='Delete this To-Do'><i class='fas fa-trash'></i></span> " + todotext + "</li>");
}else{
swal("Ooops!", "Word limit Exceeded", "info");
}
}
});
//to hide input area
$(".fa-plus").click(function(){
$("input[type='text'").fadeToggle();
});
// to delete all todos
$(".fa-cog").click(function(){
$("li").fadeOut(500, function(){
$("li").remove();
});
});