Advertisement
Guest User

Untitled

a guest
Nov 28th, 2014
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. <a href="#" class="scrollup">Scroll</a>
  2.  
  3. <script type="text/javascript">
  4. $(document).ready(function(){
  5.  
  6. $(window).scroll(function(){
  7. $("html, body").stop();
  8. if ($(this).scrollTop() > 100) {
  9. $('.scrollup').fadeIn();
  10. } else {
  11. $('.scrollup').fadeOut();
  12. }
  13. });
  14. $.clicked = false;
  15. if ($.clicked == false){
  16. $('.scrollup').click(function(){
  17. $.clicked = true;
  18. $("html, body").stop().animate({ scrollTop: 0 }, 600);
  19. return false;
  20. });
  21. }
  22. });
  23. </script>
  24.  
  25. $("html, body").stop().animate(
  26. --------------^^^^^^^^----
  27.  
  28. $(window).scroll(function(){
  29. $("html, body").stop();
  30.  
  31. $(function() {
  32. $('button').hide();
  33. $(window).scroll(function() {
  34. if ($(this).scrollTop() >= 50) { // If page is scrolled more than 50px
  35. $('#return-to-top').fadeIn(200); // Fade in the arrow
  36. } else {
  37. $('#return-to-top').fadeOut(200); // Else fade out the arrow
  38. }
  39. });
  40. $('#return-to-top').click(function() { // When arrow is clicked
  41. $('body,html').animate({
  42. scrollTop: 0 // Scroll to top of body
  43. }, 500);
  44. });
  45. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement