倒计时---定时器
console.log(Date.now());
//定時1秒后執行
var timeout=setTimeout(changebackgroundcolor,1000);
//循環執行
var timeout=setInterval(changebackgroundcolor,1000);
具體項目
<!DOCTYPE html>
<html lang="en">
<head>
? ? <meta charset="UTF-8">
? ? <meta http-equiv="X-UA-Compatible" content="IE=edge">
? ? <meta name="viewport" content="width=device-width, initial-scale=1.0">
? ? <title>Document</title>
</head>
<style>
#box1{
? ? width: 100px;
? ? height: 100px;
background-color: red;
}
</style>
<body>
? ? <div id="box1"></div>
 ?
</body>
<script>
var flag=true;
function changebackgroundcolor(){
? ? var box=document.getElementById("box1");
? ? if(flag){
? ? ? ? box.style.backgroundColor="black";
? ? ? ? flag=false;
console.log(Date.now());
? ? }
else{
? ? box.style.backgroundColor="#bfa";
? ? ? ? flag=true;
console.log(Date.now());
}
}
console.log(Date.now());
//定時1秒后執行
// var timeout=setTimeout(changebackgroundcolor,1000);
//循環執行
var timeout=setInterval(changebackgroundcolor,1000);
</script>
</html>
?
?
總結
                            
                        - 上一篇: direct3d D3DXCreateT
 - 下一篇: 新站的几种简单的推广方法