diff --git a/index.html b/index.html index fa08eb38..1cbc451b 100644 --- a/index.html +++ b/index.html @@ -66,6 +66,10 @@

Shopping List

- + + - \ No newline at end of file + diff --git a/script.js b/script.js new file mode 100644 index 00000000..f40a0b8d --- /dev/null +++ b/script.js @@ -0,0 +1,48 @@ +//FORM: +//Create code that stops form from being submitted. Also +//should code so that it adds a child list to the li items +$("form").submit(function(event) { + event.preventDefault(); + var itemValue = $("#shopping-list-entry").val(); + console.log(itemValue); + if (itemValue.length === 0) { + alert('Cannot be blank!') + } else { + let newRow = $(` +
  • + ${itemValue} +
    + + +
    +
  • `); + $(".shopping-list").append(newRow) + } + //add new list item to ul, add shopping item text to span, + //add buttons - delete and check - and add labels to buttons +}); + + +//SHOPPING-ITEM-TOGGLE: +//create functionality that, when pressed, crosses or +//uncrosses the selected item from the list + +// $(".shopping-item-toggle").click(function(event) { +$(document).on("click", ".shopping-item-toggle", function(event) { + event.preventDefault(); + console.log($(this)); + $(this).parent().parent().find(".shopping-item").toggleClass("shopping-item__checked"); + //$(this).addClass(".shopping-item__checked"); +}) + +//SHOPPING-ITEM-DELETE: +//create functionality that deletes this + +$(document).on("click", ".shopping-item-delete", function(event) { + event.preventDefault(); + $(this).parent().parent().remove(); +})