does anyone know how to automatically jump to the bottom of a scrollable area by event in jquery ( or even javascript if no easy jquery solution)?
regards
What you need to do is use the clearInterval() function when it gets to the top, set the scrollbar to the bottom of the page, then reset the interval using setInterval(). To detect when the scrollbar is at the top of the document/element depends on the browser.
To use you just need to press CTRL+ Left click of your mouse and drag the mouse a bit in the direction you want to scroll the page. For example, if you want to scroll up to the page automatically, click CTRL+ left click and slightly move your mouse upwards, the tool will start scrolling up the page.
use css position top keep it at the bottom {position : relative; bottom:0;} . Remove the css property once the user has scroll.
<div id="myDiv" style="height:300px;overflow:auto;"> <p>my content here</p> </div> var myDiv = $("#myDiv"); myDiv.animate({ scrollTop: myDiv.attr("scrollHeight") - myDiv.height() }, 3000);
Edit:
jQuery 1.6 introduced .prop
and changed the meaning of .attr
thus $("#someDiv").attr("scrollHeight")
won't work anymore.
Need to be changed to: $("#someDiv").prop("scrollHeight")
Reference.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With