forked from Thinkful-Ed/shopping-list
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
31 lines (26 loc) · 921 Bytes
/
app.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
$(document).ready(function() {
$("#js-shopping-list-form").submit(function(event) {
event.preventDefault();
$(".shopping-list").append(
"<li>" +
'<span class="shopping-list">' + $("#shopping-list-entry").val() + '</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>'
);
$(this)[0].reset();
});
$(".shopping-list").on("click", ".shopping-item-delete", function(event){
$(this).closest("li").remove();
});
$(".shopping-list").on("click", ".shopping-item-toggle", function(event){
$(this).closest("li").find(".shopping-item").toggleClass(
"shopping-item__checked");
});
})