rob.m rob.m - 1 year ago 75
jQuery Question

How to scrollTop when html, body is set to height: 100%?

The following won't work unless I remove

height: 100%
from body and html. However, i need that style as I am using it for other elements on the page.


<a href="#" id="scrollTop">Back to top</a>


$(window).animate({scrollTop: 0}, 'slow');

Even tried the following with still negative results

$("body, html").animate({scrollTop: 0}, 'slow');


html, body {height:100%; min-height:100%;}

Answer Source

Got the issue, thanks to comments I noticed I had body: overflow-x:hidden which means scrollTop isn't working when we are using overflow on body, html

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download