jQuery“下推"列在Twitter主页中 [英] jQuery "push down" list as in Twitter's home page
问题描述
我需要一个类似Twitter主页中的jQuery列表.这意味着要列出许多帖子,然后在X秒后,将另一个帖子插入列表的顶部,并产生效果,然后将其余帖子向下推.
I need a jQuery list like in Twitter's home page. This means, to have many posts listed, and then, after X seconds, another post is inserted at the top of the list, with an effect, and pushing the rest of them down.
推荐答案
确切的操作方法取决于您要添加的内容.但是,作为基本原则,您可以遵循以下方法:
Exactly how to do this depends on what you want to add. As a basic principle, however, you can follow this method:
HTML:
<div id="container">
<div>First item</div>
<div>Second item</div>
</div>
JavaScript:
Javascript:
$(document).ready(function(){
setInterval(function(){
$('<div>New item</div>').hide().prependTo('#container').slideDown('slow');
},4000);
});
这将每4秒在容器顶部添加一个新的div.添加后,它将逐渐向下滑动,并将相应的现有div向下推.
This will add a new div to the top of the container every 4 seconds. When it is added, it will slide down gradually and will push the existing divs down accordingly.
如果您可以提供有关数据来源的一些信息,我可以建议您如何实现数据.
If you can provide some information about where your data is coming from, I can suggest how you might implement it.
这篇关于jQuery“下推"列在Twitter主页中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!