How to - Bootstrap 4 Scrollspy

What I want to achieve:
I want to use variable for dynamic attribute > styling > class toggle

Example how I plan to use it:
When user click anchor link or scroll top the page, I want to change class of the current div header and nav link to active. I expect when user click the link, or just scrolling the page, the class will dynamically change.
Note: I use script to scrolltop a div with offset 80 px when user click anchor link pointing to it.

Possible? Or is there better way to implement it.

Community Page
Last updated: