开发者

Keeping the scroll to bottom

开发者 https://www.devze.com 2022-12-27 16:47 出处:网络
I have a shoutbox and I want to keep the scroll to bottom same as IM windows开发者_如何学C. My html is

I have a shoutbox and I want to keep the scroll to bottom same as IM windows开发者_如何学C.

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


Whenever an item is added, do the following:

document.getElementById('shoutContainer').scrollTop = 10000;
// or some other big number

edited


I'm not sure you can do this with CSS alone, but here's a great jQuery solution: Ajaxdaddy shoutbox.

Here is a free shout box service to keep your client happy:

Free shoutboxes.

I just made one to make sure it's ok, example here.

0

精彩评论

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

关注公众号