// Function to highlight the current page in the navbar function highlightCurrentPage()…
- User
// Function to highlight the current page in the navbar function highlightCurrentPage() { // Get the current page filename const currentPage = window.location.pathname.split('/').pop() || 'index.html'; // Default to index.html if no filename
// Find all nav links const navLinks = document.querySelectorAll('.nav-links a');
// Loop through links and add 'active' class to the current page navLinks.forEach(link => { const href = link.getAttribute('href'); if (href === currentPage) { link.classList.add('active');
// Add active class to SVG icons const svgIcons = link.querySelectorAll('.magnifying-glass, .home-icon'); svgIcons.forEach(icon => { icon.classList.add('active-icon'); }); // If this is in a dropdown, also highlight parent const parentDropdown = link.closest('.dropdown'); if (parentDropdown) { const parentLink = parentDropdown.querySelector('.dropdown-toggle'); if (parentLink) { parentLink.classList.add('active-parent'); } } }}); }
Modify this funktion to also add the active atribute to the .logo class
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.