I see this fiddle sample here
I want when "to the top" appear, an click! should scroll to the top smoothly or slow
$(window).scroll(function() { if ($(this).scrollTop()) { $('#toTop').fadeIn(); } else { $('#toTop').fadeOut(); } });
This code must be added just after we included jQuery, in new <script></script> tags: $(function () { $(window). scroll(function() { if ($(this). scrollTop() - 200 > 0) { $('#to-top').
Utilize the <a> tag. At the top of your website, put an anchor with specified name. Then your "back to top" link points to it.
Method 1: Using window.scrollTo() The scrollTo() method of the window Interface can be used to scroll to a specified location on the page. It accepts 2 parameters the x and y coordinate of the page to scroll to. Passing both the parameters as 0 will scroll the page to the topmost and leftmost point.
$("#toTop").click(function () { //1 second of animation time //html works for FFX but not Chrome //body works for Chrome but not FFX //This strange selector seems to work universally $("html, body").animate({scrollTop: 0}, 1000); });
http://jsfiddle.net/fjXSq/161/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With