troubleshooting Question

Highlight menu item on scroll

Avatar of Mark Bran
Mark Bran asked on
6 Comments1 Solution70 ViewsLast Modified:
Need help here ....
I am having difficulty here .... onClick the below code highlights my menu item as it should but
this is with the click event
I need to do the same thing but onScroll I need to highlight the menu item as I am doing below ... I guess using the active class

1. When user scrolls to next section  the menu item should be highlighted - using the active class

  let actLink = document.querySelector("#homeLink");
actLink.classList.add("active"); // Add .active class to Home main Landing Page
// onclick remove and or add .active
function activeFunction(e) {
   let els = document.querySelector(".active");
   if (els !== null) {
   } = "active";

Open in new window

Join our community to see this answer!
Unlock 1 Answer and 6 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros