Jump to content

Changing color of Nav element when its active

Recommended Posts

  • Replies 2
  • Views 363
  • Created
  • Last Reply
Posted
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

<style>
.header a.active-page {
  color: red !important;
}
</style>
<script>
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";
	}  
});

</script>

image.thumb.png.2fc7641fa9ed66e16950237861efaff3.png

BeyondSpace - Squarespace Website Developer

🖼️ Lightbox Studio (Pinch/Zoom images, videos - PDFs Lightbox - ...) </>  🗓️ Delivery Date Picker (Date picker form field)
Gallery block 7.1 workaround </> 🤖 Ask me anything

  • 2 weeks later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.