 <p>This problem is quite simple to solve even without jQuery or similar in plain JavaScript. Here it is for your example:</p> <pre><code>var next = (function (sections) { function getTop(node) { return node ? node.offsetTop + getTop(node.offsetParent) : 0; } return function () { var i, nodeTop, top = window.pageYOffset; for (i = 0; i &lt; sections.length; i += 1) { nodeTop = getTop(document.getElementById(sections[i])); if (nodeTop &gt; top) { window.scrollTo(window.pageXOffset, nodeTop); return; } } }; }(['top', 'fe1', 'fe2', 'fe3', 'fe4', 'fe5'])); </code></pre> <p>The code is quite general, so you can pass any section ids you want (they just need to appear in the correct order).</p> <p>We use two standard DOM properties/functions here <code>window.pageYOffset</code> and <code>window.scrollTo()</code> to get and set vertical offset of the window (<code>window.pageXOffset</code> is used to keep horizontal offset the same). To get the vertical offset of the section start I defined <code>getTop</code> function using simple recursion (jQuery uses similar code IMHO).</p> <p>Resulting function <code>next()</code> is defined in a self-invoking closure to hide the implementation and helper function. To use it after this code is run, you simply call</p> <pre><code>next(); </code></pre> <p>I tested this code, so I am quite confident it works :).</p>