1, Place the javascript code inside head tag:
2, Place the style code in css file:
3, Place the html code in footer just above the closing of body tag i.e before </body>
<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>
2, Place the style code in css file:
.scrollup
{
position:fixed;
display:none;
right:50px;bottom:100px;
}
3, Place the html code in footer just above the closing of body tag i.e before </body>
<a href="#" class="scrollup">image or text (scroll to top)</a>
No comments:
Post a Comment