views:

82

answers:

2

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 and 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?

+1  A: 

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

$("#theDiv").mouseover(function() {
    $(this).scrollTop($(this).height());
});
karim79
It's interesting how we both read the question differently. I thought he wanted to scroll the body to get the bottom of the div in view, but really either of us could be right :-)
Andy E
I hope it works i can't try it now :]
vanjadjurdjevic
A: 

You can modify the scrollTop property of the body:

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