Posted By

kyllle on 04/08/12


Tagged

jquery scrolltop


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

BrockSamsom


Show scroll to top if top != 0


 / Published in: jQuery
 

If scrollTop isnt equal to 0 then show #toTop

  1. //Hide/Show #toTop
  2. jQuery(window).scroll(function () {
  3. if (jQuery(this).scrollTop() != 0) {
  4. jQuery('#toTop').fadeIn();
  5. } else {
  6. jQuery('#toTop').fadeOut();
  7. }
  8. });
  9. //Scroll to top
  10. jQuery('#toTop').click(function () {
  11. jQuery('body,html').animate({
  12. scrollTop: 0
  13. }, 300);
  14. });

Report this snippet  

You need to login to post a comment.