Scroll to top

Scroll to top

WordPress
Amitpal Singh

1, Place the javascript code inside head tag:

[html]
<script type="text/javascript">
$(document).ready(function(){

$(window).scroll(function(){
if ($(this).scrollTop() > 100) {
$(‘.scrollup’).fadeIn();
} else {
$(‘.scrollup’).fadeOut();
}
});

$(‘.scrollup’).click(function(){
$("html, body").animate({ scrollTop: 0 }, 600);
return false;
});

});
</script>
[/html]

2, Place the style code in css file:

[css]
.scrollup
{
position:fixed;
display:none;
right:50px;bottom:100px;
}
[/css]

3, Place the html code in footer just above the closing of body tag i.e before

body

[html]
<div class="scrollup">image or text (scroll to top)</div>
[/html]