From 3659831419447226330a261a42f0b8df53f1c29d Mon Sep 17 00:00:00 2001 From: Lauren Laskerr Date: Sun, 15 Sep 2019 15:51:38 -0400 Subject: [PATCH] probably could do a thing where it's responsive based upon the input in the span, but this is fine --- starter-code/index.html | 27 ++++++++++++++------------ starter-code/pizza.js | 43 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 12 deletions(-) diff --git a/starter-code/index.html b/starter-code/index.html index 189a3311..5ad617c8 100755 --- a/starter-code/index.html +++ b/starter-code/index.html @@ -26,10 +26,10 @@

Pizza Builder

  • - +
  • - +
  • @@ -41,13 +41,13 @@

    Your pizza's price

    $10 cheese pizza - $21 + $13 @@ -268,9 +268,9 @@

    Your pizza's price

    31
    33
    -
    +
    -
    +
    @@ -289,7 +289,10 @@

    Your pizza's price

    - - + + diff --git a/starter-code/pizza.js b/starter-code/pizza.js index b473d048..4280e6e8 100755 --- a/starter-code/pizza.js +++ b/starter-code/pizza.js @@ -1 +1,44 @@ // Write your Pizza Builder JavaScript in this file. +$(document).ready(function(){ + var totalPrice = 13; + $(".btn-pepperonni").click(function(){ + $(".pep").toggle(); + $(this).toggleClass('active'); + $("li:contains(pepperonni)").toggle(); + if ($(this).hasClass("active")) totalPrice += 1; + else totalPrice -= 1; + $("#total").html(totalPrice) + }); + $(".btn-mushrooms").click(function(){ + $(".mushroom").toggle(); + $(".btn-mushrooms").toggleClass('active'); + $("li:contains(mushrooms)").toggle(); + if ($(this).hasClass("active")) totalPrice += 1; + else totalPrice -= 1; + $("#total").html(totalPrice) + }); + $(".btn-green-peppers").click(function(){ + $(".green-pepper").toggle(); + $(".btn-green-peppers").toggleClass('active'); + $("li:contains(green peppers)").toggle(); + if ($(this).hasClass("active")) totalPrice += 1; + else totalPrice -= 1; + $("#total").html(totalPrice) + }); + $(".btn-sauce").click(() => { + $('.sauce').toggleClass('sauce-white'); + $(".btn-sauce").toggleClass('active'); + $("li:contains(white)").toggle(); + if ($(".btn-sauce").hasClass("active")) totalPrice += 3; + else totalPrice -= 3; + $("#total").html(totalPrice) + }) + $(".btn-crust").click(() => { + $('.crust').toggleClass('crust-gluten-free'); + $(".btn-crust").toggleClass('active'); + $("li:contains(gluten-free)").toggle(); + if ($('.btn-crust').hasClass("active")) totalPrice += 5; + else totalPrice -= 5; + $("#total").html(totalPrice) + }) +}); \ No newline at end of file