开发者

Scrolling dynamically to the end of the page

开发者 https://www.devze.com 2022-12-27 00:36 出处:网络
I have a link which animates some div\'s height when its hovered, but the div has a big height and it goes beyond the visible bottom-end of the screen.

I have a link which animates some div's height when its hovered, but the div has a big height and it goes beyond the visible bottom-end of the screen.

I have to scroll to see the data an开发者_StackOverflowd when I scroll I leave the hover area and the div toggles it's height to 0px.

How to automatically scroll to the end of the div when it toggles?


Try setting the DIV's scrollTop property to it's height, e.g.:

$("#theDiv").mouseover(function() {
    $(this).scrollTop($(this).height());
});


You can modify the scrollTop property of the body:

// Scroll all the way to the bottom
document.body.scrollTop = document.body.scrollHeight;
0

精彩评论

暂无评论...
验证码 换一张
取 消