Showing posts with label How to Add Page Scroll to Top using jQuery. Show all posts
Showing posts with label How to Add Page Scroll to Top using jQuery. Show all posts

Friday, 25 April 2014

Scroll To Top functionality in Magento


Scroll To Top functionality in Magento

Open your header.phtml file and write below code..

<a title="Scroll To Top" class="scrollup" href="javascript:void(0);" style="display: none;">Scroll</a>
<script type="text/javascript">
jQuery(document).scroll(function(){
if (jQuery(this).scrollTop() > 100) {
jQuery('.scrollup').fadeIn();
} else {
jQuery('.scrollup').fadeOut();
}
});
jQuery('.scrollup').click(function(){
jQuery("html, body").animate({ scrollTop: 0 }, 600);
return false;
});
</script>

Note : Please include jQuery library in head section.

That's it... Enjoy Chandresh rana's Coding.... :)