Tuesday, 12 April 2011

Back to Top with Jquery


  1. Login ke blogger masing-masing, kemudian pilih design, dan pilih Edit HTML.
  2. Setelah masuk ke edit HTML, jangan lupa ceklist Expand Widget Templates.
  3. Cari kode </head>, massukan script di bawah ini tepat di atas code </head>
<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>
     4. cari kode <body> dan ubah menjadi <body id='top'>
     5. Masukkan kode HTML berikut sebelum </body>
<div id='goingtop'>
<a href='#top' title='Top'><img src='http://i627.photobucket.com/albums/tt351/testemplates/goto_top.gif' style='right:20px; bottom:20px; position: fixed;'/></a></div>
     6. klik save tamplate, selesai.

    No comments:

    Post a Comment