Skip to content

Latest commit

 

History

History
59 lines (45 loc) · 796 Bytes

readme.md

File metadata and controls

59 lines (45 loc) · 796 Bytes

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);