How to add jQuery Plugin: Scroll to Top to Blogger

After reading an article "jQuery Plugin: Scroll to Top" by Craig Wilson a couple of weeks ago, here is how to add it to your Blogger.

There is a similar code by David Walsh here. But I am using a code by Craig.

You can see the action in this page. You just need to scroll down a bit and you will see a ^Scrol to Top box on the right bottom. By clicking it you go to the top of the page.

1. Add the following HTML before your </body> tag.

<a href="#" id="toTop">^ Scroll to Top</a>

2. Add the following CSS code in your Blogger CSS code.

/* to top */
#toTop { width:100px;background:#F4FFBF;border:1px solid #ccc;text-align:center;padding:5px;position:fixed;bottom:10px;right:10px;cursor:pointer;color:#666;text-decoration:none; }

3. Add the following jQuery codes just before </body> tag.

<script src='' type='text/javascript'></script>
<script type='text/javascript'>
* jQuery Plugin: Scroll to Top
* by Craig Wilson, Ph.Creative (
* Copyright (c) 2009 Ph.Creative Ltd.
* Description: Adds an unobtrusive "Scroll to Top" link to your page with smooth scrolling.
* For usage instructions and version updates to go
* Version: 1.0, 12/03/2009

$(function(){$.fn.scrollToTop=function(){$(this).hide().removeAttr("href");if($(window).scrollTop()!="0"){$(this).fadeIn("slow")}var scrollDiv=$(this);$(window).scroll(function(){if($(window).scrollTop()=="0"){$(scrollDiv).fadeOut("slow")}else{$(scrollDiv).fadeIn("slow")}});$(this).click(function(){$("html, body").animate({scrollTop:0},"slow")})}});

$(function() {

Related Posts :

blog comments powered by Disqus
^ Scroll to Top