-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscripts.js
More file actions
30 lines (24 loc) · 795 Bytes
/
Copy pathscripts.js
File metadata and controls
30 lines (24 loc) · 795 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
27
28
29
30
function newItem() {
// Adding a new Item to the list of items:
let li = $('<li></li>');
let inputValue = $('#input').val();
li.append(document.createTextNode(inputValue));
if (inputValue === '') {
alert('You must write something!');
} else {
$('#list').append(li);
}
// Crossing out an item from the list of items:
li.on('dblclick', function crossOut() {
li.addClass('strike');
});
// 3.1. Adding the delete button "X":
let crossOutButton = $('<crossOutButton>X</crossOutButton>');
li.append(crossOutButton);
// 3.2. Adding class delete from css
crossOutButton.on('click', function deleteListItem() {
li.addClass('delete');
});
// 4. Reordering the items:
$('#list').sortable();
}