I want to know a code for continuous website that if i scroll to the bottom and will get back to top, and otherwise.
i already in a half way that i used this code for the bottom page :
$(document).ready(function() {
$(document).scroll(function(){
if (document.documentElement.clientHeight + $(window).scrollTop() >= $(document).height()) {
$(document).scrollTop(0);
}
});
});
how can i make conversely? from top to the bottom page?
EDIT:
$(document).ready(function() {
$(document).scroll(function(){
if (document.documentElement.clientHeight + $(window).scrollTop() >= $(document).height()) {
$(document).scrollTop(0);
}
else if ($(window).scrollTop() <= 0) {
$(document).scrollTop($(document).height());
}
});
});
i tried that code and it works, but i think there is a little bug there, i need to scroll a bit more to get to bottom from top or otherwise, why is that happen?
Thanks