Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

8
  • 1
    A little more help would be great! Where exactly do I put the scrollTo command, e.g. $.scrollTo('#'+target', 1000);? Commented Jan 3, 2012 at 11:54
  • 3
    The scrollspy doesn't handle the movement to the element, this is done natively by the browser. All scroll spy does is change the selected element as the user scrolls. Here is a quick implementation of scrollTo that should help: jsfiddle.net/flabbyrabbit/69z7x Commented Jan 3, 2012 at 12:22
  • 1
    Brilliant! One final question, can I set a top-offset? Please see here for reference: jsfiddle.net/69z7x/5 So here there'd be a 200px offset. Commented Jan 3, 2012 at 12:56
  • 2
    Try this: $.scrollTo(target, 1000, {offset:-200}); Commented Jan 3, 2012 at 13:21
  • 5
    no need to update any functions, you can just add data-offset="200" to the body Commented Jun 16, 2012 at 12:33