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(); + } +};