This version is old school.
Please find jQuery plugins on npm.
Mindfor jQuery affix
by Alexander Fomin
The affix will reflect which part of the content the user is reading/looking at. But the affix can also be used to jump to a certain section in the content.