Skip to content
Advertisement

Adding active class to menu when section changes

when i scroll the page, i want to add class active menu item. i can get the current div id like this var currSection = $(this).attr(‘id’). im stuck with id and data-id matching. here is the codes. ty for helping guys.

JavaScript
JavaScript
JavaScript

Advertisement

Answer

Change scroll event listener to this

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement