开发者

How do I expire elements using Javascript / Prototype?

开发者 https://www.devze.com 2023-03-31 08:15 出处:网络
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.

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

精彩评论

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