我了解如何使用 Ajax.Updater 发出请求并将结果插入到 DIV 中。
我不明白的是如何在一段时间后使这些元素过期。
因此在这种情况下,将收到报告并将其添加到列表中。但它们也应该在列表中几秒钟后过期/删除。
我该怎么做?
最佳答案
当插入元素时,可以设置一个超时时间(setTimeout
)在一段时间后删除元素:
new Ajax.Updater('container', {
onComplete: function() {
setTimeout(function() {
// remove the element here
}, 60*1000); // 60 seconds
}
});
关于javascript - 如何使用 Javascript/Prototype 使元素过期?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7213617/