单击使用相同的页面锚点后保持链接处于活动状态

基本上我有一个具有相同页面锚点的固定导航栏,我想在点击链接并将其带到页面的该部分后保持链接处于活动状态。 如果到另一个页面的链接,这很简单,但我无法弄清楚如何在这里。

这就是我所拥有的。 我将向您展示第一个链接和部分,因为解决方案很可能与以下链接相同。 我没有写任何CSS,因为我不知道该怎么做。

 

A New Way
To Schedule
Everything

One calendar that lets you manage schedules for your team
and your spots, all in one calendar, with options of sharing your
own personal schedule, and you can accept and decline
appointments with any device.

使用jQuery,您只需在链接上切换active类:

 $('#navContent a').click(function(){ /* remove class from prior active link*/ $('.activeLinkClass').removeClass('activeLinkClass'); /* "this" is current link clicked*/ $(this).addClass('activeLinkClass'); });