Skip to content

Commit

Permalink
Update 01-mobile-menu.js
Browse files Browse the repository at this point in the history
  • Loading branch information
ViktorSvertoka committed Dec 16, 2023
1 parent 2189479 commit 89f140f
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions src/js/01-mobile-menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
};

0 comments on commit 89f140f

Please sign in to comment.