-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtodo.js
59 lines (51 loc) · 1.25 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
var html = '<div class="todo"><h5 class="delete"></h5><p>';
var htmle = '</p></div>';
var k = false;
var show = true;
$(document).ready(function(){
$("input").keypress(function(e){
if(e.which == 13) {
var task = $("input").val();
$(".todos").prepend(html+task+htmle);
$("input").val('');
k = false;
}
});
$("input").click(function () {
if(k===false){
k = true;
$('input').val('');
}
});
$('input').on("focusout" ,function(){
$('input').val('Add new To-do');
});
$('.plus').click(function(){
if(show == true){
$('input').slideToggle();
show = false;
}
else {
$('input').slideToggle('slow');
show = true;
}
});
$(document).on( "click", ".todo p", function(){
$(this).css("text-decoration", "line-through");
} );
$(document).on( "mouseenter", ".todo p", function(){
$(this).prev().animate({
width: "5%"
}, 500 );
$(this).prev().html('<i class="fa fa-trash-o" aria-hidden="true"></i>');
});
$(document).on( "mouseleave", ".todo", function(){
$(this).children('.delete').animate({
width: "0"
}, 500 );
$(this).children('.delete').html('');
});
$(document).on( "click", ".delete", function(){
$(this).parent().fadeOut();
});
});