Return to Snippet

Revision: 22430
at January 12, 2010 12:38 by 1man


Initial Code
/**
 * HTML setup as a list of anchors set vertically down the page
 */

//Click an anchor
$("a").click(function(e){
	//Animate the html and body
	$("html, body").animate({
		//Set the CSS property scrollTop to the next anchors top value
		scrollTop: $(this).parent('li').next().find("a").offset().top
	}, 1000);//1 second scroll (add some easing for a smoother look)
	return false;
});

Initial URL


Initial Description
Example in 'jQuery enlightenment'

Simple way to jump smoothly down the page without the use of a plugin.

Initial Title
Simple jQuery page scroller

Initial Tags
page, jquery

Initial Language
jQuery