A scrollToTop jQuery Plugin
-
Include necessary JS files
<script src="jquery.js"></script> <script src="jquery.scrollToTop.min.js"></script>
-
Add scrollToTop CSS file
<link rel="stylesheet" href="style.css" />
-
Create a link element
<a href="#top" id="toTop"></a>
-
Fire plugin using jQuery selector
$(function() { $("#toTop").scrollToTop(); });
-
Option: pass in a number to control scroll speed. Default: 800.
$(function() { $("#toTop").scrollToTop(1000); });
- IE7 and above, Firefox, Chrome, Safari and Opera
Released under the MIT license.