AJAX聊天,自动滚动窗口 [英] AJAX chat, auto scroll window
本文介绍了AJAX聊天,自动滚动窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个AJAX聊天的输出信息与溢出的div:自动所以,如果它变得太长时间,滚动条出现。有没有一种方法可以让它自动滚动至底部每当一个新的消息添加? preferably使用jQuery?
I have an AJAX chat that outputs the messages to a div with overflow: auto so if it gets too long, the scroll bar comes up. Is there is a way to have it auto scroll to the bottom whenever a new message is added? Preferably using jQuery?
推荐答案
它会与下面的行来完成
$("#youChatDiv").attr({ scrollTop: $("#youChatDiv").attr("scrollHeight") });
这样做是设置滚动到自己的元素的高度
what this does is set the scroll to the height of the own element
只是调用每一个新的消息:)
just call that with every new message :)
欢呼声
这篇关于AJAX聊天,自动滚动窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文