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
}
});
精彩评论