Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
cocktails/app.js
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
47 lines (46 sloc)
2 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function() { | |
// Hover to show the recipe | |
$(".card").hover( | |
function() { | |
const card = $(this); | |
let recipe; | |
switch (card.find("h3").text()) { | |
case "Mistletoe Martini": | |
recipe = "Mix vodka, cranberry juice, and lime juice. Serve chilled."; | |
break; | |
case "Snowfall Sangria": | |
recipe = "Combine white wine, apple cider, and cinnamon sticks."; | |
break; | |
case "Winter Wonderland": | |
recipe = "Combine sparkling water, pomegranate juice, and garnish with rosemary."; | |
break; | |
case "Holiday Mule": | |
recipe = "Mix vodka, ginger beer, and cranberry juice. Garnish with lime."; | |
break; | |
case "Festive Berry Punch": | |
recipe = "Mix berries, sparkling water, and mint leaves."; | |
break; | |
default: | |
recipe = "Recipe not available."; | |
} | |
card.find("p").text(recipe); | |
}, | |
function() { | |
// Reset the text on mouse leave | |
const mainIngredients = { | |
"Mistletoe Martini": "Main Ingredients: Vodka, cranberry juice, lime", | |
"Snowfall Sangria": "Main Ingredients: White wine, apple cider, cinnamon", | |
"Winter Wonderland": "Main Ingredients: Sparkling water, pomegranate juice, rosemary", | |
"Holiday Mule": "Main Ingredients: Vodka, ginger beer, cranberry", | |
"Festive Berry Punch": "Main Ingredients: Mixed berries, sparkling water, mint" | |
}; | |
const drinkName = $(this).find("h3").text(); | |
$(this).find("p").text(mainIngredients[drinkName]); | |
} | |
); | |
// Click to show calories | |
$(".card").click(function() { | |
const calories = $(this).data("calories"); | |
$(this).find("p").text(`Calories: ${calories}`); | |
}); | |
}); |