开发者

How do I expire elements using Javascript / Prototype?

I understand how to use Ajax.Updater to make requests and insert the results into a DIV.

What I do not understand is how to expire those elements after some time period.

So in t开发者_开发知识库his scenario reports will be received and will be added to the list. But they should also be expired / removed after a few seconds in the list.

How do I do that?


When the element is inserted, you can set a timeout (setTimeout) to delete the element after some time:

new Ajax.Updater('container', {
    onComplete: function() {
        setTimeout(function() {
            // remove the element here
        }, 60*1000); // 60 seconds
    }
});
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜