From 89f140ff6ee3078d2372f777b7ffa3e35b3b3385 Mon Sep 17 00:00:00 2001 From: Viktor Svertoka <115661003+ViktorSvertoka@users.noreply.github.com> Date: Sat, 16 Dec 2023 18:10:49 +0200 Subject: [PATCH] Update 01-mobile-menu.js --- src/js/01-mobile-menu.js | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/js/01-mobile-menu.js b/src/js/01-mobile-menu.js index a8e9f78..fa088d4 100644 --- a/src/js/01-mobile-menu.js +++ b/src/js/01-mobile-menu.js @@ -60,24 +60,24 @@ menuNavLinks.forEach(link => { // Переключение кнопок-ссылок -// document.addEventListener('DOMContentLoaded', () => { -// const currentPath = window.location.pathname; +document.addEventListener('DOMContentLoaded', () => { + const currentPath = window.location.pathname; -// if (currentPath.includes('index.html')) { -// const homeButton = document.getElementById('homeButton'); -// homeButton.classList.add('active'); -// homeButton.addEventListener('click', handleClick); -// } else if (currentPath.includes('favorites.html')) { -// const favoritesButton = document.getElementById('favoritesButton'); -// favoritesButton.classList.add('active'); -// favoritesButton.addEventListener('click', handleClick); -// } -// }); + if (currentPath.includes('index.html')) { + const homeButton = document.getElementById('homeButton'); + homeButton.classList.add('active'); + homeButton.addEventListener('click', handleClick); + } else if (currentPath.includes('favorites.html')) { + const favoritesButton = document.getElementById('favoritesButton'); + favoritesButton.classList.add('active'); + favoritesButton.addEventListener('click', handleClick); + } +}); -// const handleClick = event => { -// if (!event.currentTarget.classList.contains('active')) { -// alert('Button clicked!'); -// } else { -// event.preventDefault(); -// } -// }; +const handleClick = event => { + if (!event.currentTarget.classList.contains('active')) { + alert('Button clicked!'); + } else { + event.preventDefault(); + } +};