18 lines
584 B
JavaScript
18 lines
584 B
JavaScript
document.querySelectorAll(".meal-card").forEach((card) => {
|
|
const openPricing = () => {
|
|
window.location.href = `pricing.html?mode=${encodeURIComponent(card.dataset.mode)}`;
|
|
};
|
|
|
|
card.querySelector(".card-action").addEventListener("click", openPricing);
|
|
card.addEventListener("click", (event) => {
|
|
if (event.target.closest(".card-action")) return;
|
|
openPricing();
|
|
});
|
|
|
|
card.addEventListener("keydown", (event) => {
|
|
if ((event.key === "Enter" || event.key === " ") && event.target === card) {
|
|
event.preventDefault();
|
|
openPricing();
|
|
}
|
|
});
|
|
});
|