Jump to content

Changing color of Nav element when its active

Recommended Posts

On 4/11/2021 at 4:22 PM, stringbryce said:

Site URL: http://aldenteenoteca.com

Hey can someone provide me with code to change the color of the nav item when its on that page, tried looking everywhere else not working


Add this into Advance-Code injection, change color red to whatever you like

.header a.active-page {
  color: red !important;
document.addEventListener('DOMContentLoaded', function() {	
	var currentPage = location.hash ? location.pathname + location.hash : location.hash;
	var _a = document.querySelectorAll('.header a[href*="'+currentPage+'"]');

	for (var i = 0; i < _a.length; ++i) {
	  _a[i].className += _a[i].className + " " + "active-page";



BeyondSpace - Squarespace Website Developer

🖼️ Lightbox Studio (Enable Pinch/Zoom on lightbox)
🗓️ Delivery Date Picker (Squarespace Date format)
💫 Animated Buttons (Referral URL)
🥳 Sparkplugin Customisations Browsers (Browse +100 Spark plugin customisations)
🥳 Elfsight Template Browsers (Browse +1000 Elfsight widget Templates)

If you find my answer useful, let's leave a like or upvote so others with the same issue can find their solution. Thank you!


Link to comment
  • 2 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.