Return to Snippet

Revision: 22711
at January 20, 2010 04:42 by cfleschhut


Updated Code
// HTML:
// <h1 id="anchor">Lorem Ipsum</h1>
// <p><a href="#anchor" class="topLink">Back to Top</a></p>


$(document).ready(function() {

	$("a.topLink").click(function() {
		$("html, body").animate({
			scrollTop: $($(this).attr("href")).offset().top + "px"
		}, {
			duration: 500,
			easing: "swing"
		});
		return false;
	});

});

Revision: 22710
at January 20, 2010 04:39 by cfleschhut


Initial Code
// HTML:
// <p><a href="#anchor" class="topLink">Back to Top</a></p>


$(document).ready(function() {

	$("a.topLink").click(function() {
		$("html, body").animate({
			scrollTop: $($(this).attr("href")).offset().top + "px"
		}, {
			duration: 500,
			easing: "swing"
		});
		return false;
	});

});

Initial URL
http://jsbin.com/ayulu

Initial Description
adapted from http://jquery14.com/day-05

Initial Title
jQuery  Smooth Scroll to #Anchor

Initial Tags
javascript, jquery

Initial Language
jQuery