Skip to content

AXN-Informatique/jquery-backtotop

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jQuery "back to top" plugin

Install

With NPM run the following command:

npm install @axn/jquery-backtotop --save

Usage

Load the script:

<script src="jquery.js"></script>
<script src="jquery.backtotop.js"></script>

Put a button:

<button id="btn-back-to-top">Back to top</button>

Position it:

#btn-back-to-top {
    position: fixed;
    bottom: 15px;
    right: 15px;
    display: none;
}

Run the script:

(function($) {
    $('#btn-back-to-top').backtotop();
})(jQuery);

With options:

(function($) {
    $('#btn-back-to-top').backtotop({
        showAt: 200,
        fadeInDelay: 400,
        fadeOutDelay: 400,
        scrollTopDelay: 600
    });
})(jQuery);