setTimeout
setTimeout(函數(shù),毫秒)菊卷;只執(zhí)行一次
clearTimeout();清除,不會(huì)執(zhí)行
例子:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
#guanggao{
display: none;
width: 300px;
height: 200px;
background: yellowgreen;
position: fixed;
bottom: 0;
right: 0;
}
</style>
</head>
<body>
<div id="guanggao"></div>
<script>
window.onload = function(){
var oGuangGao = document.getElementById('guanggao');
setTimeout(function(){
oGuangGao.style.display = 'block';
setTimeout(function(){
oGuangGao.style.display = 'none';
}, 5000);
}, 2000);
}
</script>
</body>
</html>
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者