Ph.Creative is a full service design and communications agency specialising in web design, SEO, internet marketing and branding.

Liverpool

London

Manchester

New York

Call us on +44(0)151 708 2280 or liverpool@ph-creative.com

Call us on +44(0)20 3301 4503 or london@ph-creative.com

Call us on +44(0)161 880 0122 or manchester@ph-creative.com

Call us on (001) 646 340 1025 or newyork@ph-creative.com

jQuery Plugin: Scroll to Top

by Craig Wilson 12 March 2009 at 10:27

Here’s a little present for you all: an unobtrusive, easy-to-install, jQuery script that adds a fading scroll to top link with animated scrolling. It works like this:

If you’re already at the top of the page, the button is invisible and doesn’t fade in to view until the user starts scrolling. When they click on the link, it pulls them back to the top of the page and fades back out again – nice and easy.

Also, the script degrades gracefully, leaving nothing but a normal <a href> link.

Installation is very simple:

Include our jQuery script on your page:

<script src="js/jquery.scroll.pack.js" type="text/javascript"></script>

Add the scroll link to your page:
<a id="toTop" href="#">^ Scroll to Top</a>

Reference your scroll link in your jQuery script:
$("#toTop").scrollToTop();

That’s it! That’s all you really need to know, you might need to add an ie6 hack to get fixed positioning, but that comes down to how you’ve styled the scroll link yourself.

You can see the script in action on this blog, scroll away. Smile

HTML/CSS files are included in the Zip file to give you an idea on styling.

Version 1.0: scroll-to-top.zip (23.68 kb)

Update: Version 2 now released!

Update: Version 3 now released!

Currently rated 4.4 by 15 people

  • Currently 4.4/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: ,

development | web design | Web Technologies

Comments

Comments are closed
 

Search

Recent Comments

Comment RSS

© Copyright Ph.Creative 2009. All rights reserved. Terms & Conditions | Privacy Policy | Sitemap (XML) | Log in

Website design by Ph.Creative

^