jQuery scroll to top

test code:

jQuery code:

jQuery(function($){
	$('a[href=#top]').click(function(){
		$('html, body').animate({scrollTop:0}, 'slow');
		return false;
	});
});

html code:

<a name="top"></a>
...page content...
<a href="#top">back to top</a>

Code works in all major browsers. Works even without javascript enabled.

VN:F [1.9.17_1161]
Rating: 0 (from 0 votes)

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">