更新时间:2023-12-03 21:26:58
您可以像这样使用setTimeout
:
setTimeout(function(){
$('#divID').remove();
}, 5000);
5000(毫秒)表示5秒.您应该用自己的div/element ID替换divID
.
The 5000 (ms) means 5 seconds. You should replace divID
with your own div/element id.
您可以使用length
确保div首先存在:
You can make sure that the div exists first using length
:
setTimeout(function(){
if ($('#divID').length > 0) {
$('#divID').remove();
}
}, 5000)