From dc7a8f8d96d44423ffcfc45470b82b37a57a803e Mon Sep 17 00:00:00 2001 From: Nicholas Hemerling Date: Tue, 7 Jul 2020 14:30:29 -0700 Subject: [PATCH 1/2] added index-js updated index-html --- index.html | 6 +++++- index.js | 44 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 index.js diff --git a/index.html b/index.html index fa08eb38..6468585c 100644 --- a/index.html +++ b/index.html @@ -66,6 +66,10 @@

Shopping List

- + + \ No newline at end of file diff --git a/index.js b/index.js new file mode 100644 index 00000000..d4132a6d --- /dev/null +++ b/index.js @@ -0,0 +1,44 @@ +/* eslint-disable no-undef */ +'use strict'; + +function addItem() { + $('#js-shopping-list-form').submit( event => { + + event.preventDefault(); + + const newItem = $(event.currentTarget).find('input[name="shopping-list-entry"]').val(); + + const newItemHTML + = `
  • ${newItem}
    + + +
  • `; + + $('.shopping-list').append(newItemHTML); + + }); +} + +function checkItem() { + $('.shopping-list').on('click', '.shopping-item-toggle', function() { + + $(this).closest('li').find('.shopping-item').toggleClass('shopping-item__checked'); + + }); +} + +function removeItem() { + $('.shopping-list').on('click', '.shopping-item-delete', function() { + + $(this).closest('li').remove(); + + }); +} + +function main() { + addItem(); + checkItem(); + removeItem(); +} + +$(main); \ No newline at end of file From d5903ec7739826f6c24488a57feb3df04246ae22 Mon Sep 17 00:00:00 2001 From: Nicholas Hemerling Date: Tue, 7 Jul 2020 20:14:04 -0700 Subject: [PATCH 2/2] fix indentation of index.js --- index.js | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/index.js b/index.js index d4132a6d..874dbf49 100644 --- a/index.js +++ b/index.js @@ -3,35 +3,33 @@ function addItem() { $('#js-shopping-list-form').submit( event => { - event.preventDefault(); - const newItem = $(event.currentTarget).find('input[name="shopping-list-entry"]').val(); - - const newItemHTML - = `
  • ${newItem}
    - - -
  • `; - + const newItemHTML = + `
  • + ${newItem} +
    + + +
    +
  • `; $('.shopping-list').append(newItemHTML); - }); } function checkItem() { $('.shopping-list').on('click', '.shopping-item-toggle', function() { - $(this).closest('li').find('.shopping-item').toggleClass('shopping-item__checked'); - }); } function removeItem() { $('.shopping-list').on('click', '.shopping-item-delete', function() { - $(this).closest('li').remove(); - }); }