I have a problem. I'm making a jquery based chat, and I'm wondering how could I append/prepend a LI element开发者_如何学编程 from a *.js file.
index.html:
<html>
...
<div id="divID">
<ul id="ulID"></ul>
</div>
</html>
chat.js:
$('#ulID').append(msg);
What I want to do is a classic chat container which will be populated, and automatically scrolled to the last LI element.
with jQM you can use the Silent Scroll method
$.mobile.silentScroll (method)
Decos: http://jquerymobile.com/demos/1.0a4.1/#docs/api/methods.html
as for adding a li to a ul list, just remember to use:
listview('refresh')
for jQM to add it's CSS/JS functionality.
I would also suggest looking at the listview docs: http://jquerymobile.com/demos/1.0a4.1/#docs/api/../../docs/lists/index.html
After the comment exchange above, it appears the actual question being asked is "How can I make an element scroll automatically, and if possible, with the scrollbar not visible?"
A similar question has already been answered here.
精彩评论