Monday, 5 October 2015

Create 'Go To Top' or 'Scroll To Top' via jQuery

Create 'Go To Top' or 'Scroll To Top' via jQuery, please follow below steps:
1. Add the below HTML code,
< div class="scroll-to-top" >
     < a href="#" id="to-top" rel="nofollow" style="outline: none;" >Top< /a >
< /div >

2. Then, include the jQuery library and add the below Javascript Code
jQuery(function($) {

    var scrollToTop = function() {
        $("a[href='#top']").click(function () {
            $("html, body").animate({scrollTop: 0}, "slow");
            return false;
    // Call the scroll to top function.


No comments:

Post a Comment

Please post any queries and comments here.