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.... :)

1 comment:

Anonymous said...

Thanks!! I was cracy with this shit, and without this the script dont works for me:

href="javascript:void(0);" style="display: none;">