Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <a href="#" class="scrollup">Scroll</a>
- <script type="text/javascript">
- $(document).ready(function(){
- $(window).scroll(function(){
- $("html, body").stop();
- if ($(this).scrollTop() > 100) {
- $('.scrollup').fadeIn();
- } else {
- $('.scrollup').fadeOut();
- }
- });
- $.clicked = false;
- if ($.clicked == false){
- $('.scrollup').click(function(){
- $.clicked = true;
- $("html, body").stop().animate({ scrollTop: 0 }, 600);
- return false;
- });
- }
- });
- </script>
- $("html, body").stop().animate(
- --------------^^^^^^^^----
- $(window).scroll(function(){
- $("html, body").stop();
- $(function() {
- $('button').hide();
- $(window).scroll(function() {
- if ($(this).scrollTop() >= 50) { // If page is scrolled more than 50px
- $('#return-to-top').fadeIn(200); // Fade in the arrow
- } else {
- $('#return-to-top').fadeOut(200); // Else fade out the arrow
- }
- });
- $('#return-to-top').click(function() { // When arrow is clicked
- $('body,html').animate({
- scrollTop: 0 // Scroll to top of body
- }, 500);
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement