forked from ammiranda/shopping_cart
-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
29 lines (23 loc) · 783 Bytes
/
script.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
/* Input field appending list */
$(document).ready(function(){
$('#submit').click(function(e) {
e.preventDefault();
var item = $('#itemName').val();
console.log(item);
$('#theList').append('<li class="item"><input type="checkbox" class="check"><span class="item2">'+ item +'</span></li>');
$('#itemName').val("");
$('#theList li input.check').last().change(function(){
$(this).siblings().toggleClass('strike');
});
});
/* Enables Sorting of li's */
$('#theList').sortable({
}).disableSelection();
/* Removes Checked Items */
$('#remove').click(function(e) {
e.preventDefault();
$('#theList li .strike').each(function () {
$(this).parent().remove();
});
});
});