A simple jquery plugin to enable scroll to top.
$ npm install jquery.scrolltop --save
$ bower install jquery.scrolltop --save
https://wabish.github.io/jquery.scrolltop/
First include the jquery.scrolltop.css
file, you can also create your own style file.
<link rel="stylesheet" href="css/scrolltop.css" />
Simply include the jquery.scrolltop.min.js
file and place the following in the head of your document (make sure jQuery is included).
<script src="../dist/lib/jquery-1.11.1.min.js"></script>
<script src="../dist/jquery.scrolltop.min.js"></script>
$(function() {
$.scrolltop();
});
$(function() {
$.scrolltop({
elemName: 'scrolltop', // 元素ID
scrollDistance: 300, // 元素开始显示的距离 (px)
scrollSpeed: 300, // 回到顶部的速度 (ms)
animationSpeed: 200 // 元素显示的速度 (ms)
});
});
This plugin is available under the MIT license.