Closed antony-k1208 closed 11 years ago
$('html, body').scrollTop(), $(document).scrollTop() and $(window).scrollTop() return always 0...
http://api.jquery.com/scrollTop/ - $('html').scrollTop() and $('body').scrollTop() should return 0.
This should scroll to the top of the page
$('html, body').animate({
scrollTop: 0
});
No it shouldnt return 0. Otherwise how can u implement a scroll to top image which should only displayed if the user is scrolling the page to a certain amount? Check the values in FF i.e. and see the result.
Anyway your solution isnt working for me in chrome. Other suggestions?
$(window).scrollTop()
I think that should do what you're looking for.
As for the animate, it should work in all browsers: http://jsfiddle.net/m4TJt/
Yeah thanks. I found the mistake, it was because of a wrong body,html css rule...
Do you recall the wrong body,html CSS rule? I think I'm having the same problem and cannot track it down.
sorry for the delay.
I think it was something like that I had a full inline div (in size of the body) and got in trouble with inner / outer divs.
Thanks a lot.......Superb.
After spent 2 days I got the solution because of this code. It's Simple but useful. This is working in every browser as well, So once again thanks...........
Thks, it took me 1 day.
Just to share some curious info. I had the same problem and apparently if the body has height: 100% set from the css the method will always return zero
@ivanVanelov You saved my sanity... Thanks!
@ivanVanelov Thank you so much!
I wanna add a scroll to top button to my website, but the event binding of (window).scroll{()}; doesnt seem to work. So ive changed it to $("body").scroll(function() {}); which works in every browser, only chrome/safari arent working. To which element i can bind the scroll event, to solve my problem?