-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
23 lines (19 loc) · 853 Bytes
/
index.js
File metadata and controls
23 lines (19 loc) · 853 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/* eslint-disable strict */
function main() {
//prevent default
$('#js-shopping-list-form').submit(event => {
event.preventDefault();
const list=($(event.currentTarget).find('input[name="shopping-list-entry"]').val());
$('ul').append(`<li><span class="shopping-item"> ${list} </span><div class="shopping-item-controls"><button class="shopping-item-toggle"><span class="button-label">check</span></button>
<button class="shopping-item-delete"><span class="button-label">delete</span></button></div></li></ul>`);
console.log(list);
});
}
$('ul').on('click', '.shopping-item-toggle', function(){
$(this).closest('li').find('.shopping-item').toggleClass('shopping-item__checked');
});
$('ul').on('click', '.shopping-item-delete', function(){
$(this).closest('li').remove();
});
// eslint-disable-next-line no-undef
$(main);