How To Add jQuery Scroll To Top Button To Blogger

Posted by Lasantha Bandara on October 29th, 2009 File Under : button, jquery2 Comments

1.Login to your blogger dashboard--> layout- -> Edit HTML

2.Scroll down to where you see </head> tag .

3.Copy below code and paste it just before the </head> tag .

<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js' type='text/javascript'/>

<script type='text/javascript'>
//<![CDATA[

$(function(){

$('a[href*=#top]').click(function() {

if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
&& location.hostname == this.hostname) {

var $target = $(this.hash);

$target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');

if ($target.length) {

var targetOffset = $target.offset().top;

$('html,body').animate({scrollTop: targetOffset}, 1000);

return false;

}

}

});

});
//]]>
</script>
<!-- end scrolltop -->

4.Now scroll down where you see <body> tag .

5.Replace <body> tag with <body id='top'> .

6.Now again scroll down where you see </body> tag .

7.Copy below code and paste it just before </body> tag:

<div id='goingtop'>
<a href='#top' title='Go Top'><img src='http://1.bp.blogspot.com/_4HKUHirY_2U/Sujr21YfikI/AAAAAAAAAGM/mPXYFXAepV4/top.png' style='right:20px; bottom:20px; position: fixed;'/></a></div>

Note: You can use any image instead of above image.

8.Click on save template and you are done.

Demo

File Under : button, jquery

2 Responses to “How To Add jQuery Scroll To Top Button To Blogger”

  1. smart baby says:

    thanks you for your information. I need this informtion to add button in my blog

  2. Harald says:

    Hi,

    I have added all parts as described, but nothing happened. I think the problem might be, that i have no tag, instead I have following code:

    Where should I insert id='top' to work correct ?

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.