/ Published in: jQuery
If scrollTop isnt equal to 0 then show #toTop
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
//Hide/Show #toTop jQuery(window).scroll(function () { if (jQuery(this).scrollTop() != 0) { jQuery('#toTop').fadeIn(); } else { jQuery('#toTop').fadeOut(); } }); //Scroll to top jQuery('#toTop').click(function () { jQuery('body,html').animate({ scrollTop: 0 }, 300); });