forked from khushi-joshi-05/Food-ordering-website
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmenu.js
19 lines (17 loc) · 841 Bytes
/
menu.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// adding items from menu to cart
document.addEventListener('DOMContentLoaded', function () {
var menuContainers = document.querySelectorAll('.menu_container');
menuContainers.forEach(function (container) {
container.addEventListener('click', function (event) {
if (event.target.classList.contains('butt')) {
var item = event.target.closest('.items');
var itemName = item.querySelector('h3').textContent;
var itemPrice = item.querySelector('p').textContent;
alert("Item added to cart successfully");
localStorage.setItem('itemName', itemName);
localStorage.setItem('itemPrice', itemPrice);
window.location.href = "cart.html";
}
});
});
});