You could use the Bootstrap ScrollSpy or Affix component - much easier!
It's as easy as setting up a nav element like so:
<nav class="col-xs-3 bs-docs-sidebar hidden-print">
    <ul class="nav nav-stacked bs-docs-sidenav fixed" id="sidebar">
        <li>
            <a href="#Group1">Content 1</a>
            <ul class="nav nav-stacked" id="sidebar">
                <li><a href="#Group1Sub1">Sub-Group 1</a></li>
                <li><a href="#Group1Sub2">Sub-Group 2</a></li>
            </ul>
        </li>
    </ul>
</nav>
And then putting your content into section elements:
    <div class="col-xs-9">
            <section id="Group1" class="group">
                <h3>Group 1</h3>
                <div id="Group1Sub1" class="subgroup">
                    <h4>Group 1 Sub 1</h4>
                </div>
                <div id="Group1Sub2" class="subgroup">
                    <h4>Group 1 Sub 2</h4>
                </div>
            </section>
</div>
And then finally it's simple as setting the target to the #sidebar:
$('body').scrollspy({
    target: '#sidebar'
});
Quickly mocked up example here: http://jsfiddle.net/LRCpp/6/
Docs: http://getbootstrap.com/javascript/