background preloader

JqMobi

JqMobi

jQuery: Smooth Scrolling Internal Anchor Links | Sycha Web Design & Development November 13th, 2010Charlie Evans Here’s a neat little jQuery trick to fancy up your internal anchor links, by making them scroll smoothly to their target as opposed to jumping instantly. Internal anchor links are very common place, e.g. This is what it looks like in action, click the following link:Scroll to comments This technique is very simple. Set up your link as you normally would, e.g. href=”#comments” (where comments is the id of your target) Add a class=”scroll” attribute to the link element, so it now looks something like this: Finally add the following jQuery code wherever is most appropriate And that’s all there is to it A common mistake in implementing this script is using “named anchors” for your target, instead of an id attribute on your target element.

Related: