I have a shoutbox and I want to keep the scroll to bottom same as IM windows.
My html is
<div id="shoutContainer">
<table id="shoutbox">
<tbody>
<!-- shouts here -->
</tbody>
</table>
</div>
My css
#shoutContainer {
height: 100px; overflow-y: scroll;
}
If its not possible through html and css. Can we achieve this in raw javascript? because I am not using any framework
If you want to check whether the user has scrolled to the bottom of the page, you can use the scroll() jQuery event. The given code piece takes the top scroll of the window, so how much the page is scrolled down, it adds the height of the visible window and checks if it is equivalent to the height of the document.
Preserve scroll position allows you to maintain the same scroll location when you transition between two screens. This applies to scroll depth in a vertical scroll, as well as the user's location inside a horizontal scrolling element. Figma automatically preserves your scroll position for Smart Animate.
To auto scroll a page from top to bottom we can use scrollTop() and height() method in jquery. In this method pass the document's height in scrollTop method to scroll.
use css position top keep it at the bottom {position : relative; bottom:0;} .
Whenever an item is added, do the following:
document.getElementById('shoutContainer').scrollTop = 10000;
// or some other big number
edited
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