-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtodo.js
More file actions
26 lines (23 loc) · 732 Bytes
/
todo.js
File metadata and controls
26 lines (23 loc) · 732 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
//Check off specific todos by clicking
$("ul").on("click", "li", function () {
$(this).toggleClass("completed")
});
//click on trash 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='fas fa-trash-alt'></i></span> " + todoText + "</li>")
}
});
$(".fa-plus").click(function () {
$("input[type='text']").fadeToggle();
});