SetInterval ("Fun ()", +)
SetInterval (fun, 1000); every 1 seconds, go to the fun function (most commonly used)
SetInterval (function () {}, 1000)
setinterval (Fun (), +) of the wrong
Countdown: <! DOCTYPE html>
<meta charset= "UTF-8" >
<title></title>
<style type= "Text/css" >
*{
margin:0;
padding:0;
}
#box {
width:100%;
height:50px;
margin:0 Auto;
Background-color:lightpink;
}
#txt {
line-height:50px;
Text-align:center;
font-size:30px;
Color:deeppink;
Font-family: "Microsoft Jas Black";
}
</style>
<script>
Window.onload = function () {
var box = document.getElementById (' box ');
var txt = document.getElementById (' txt ');
SetInterval (fun,1000);
function Fun () {
var date = new Date ();
var Wuyi = new Date (' 2018/5/1 00:00:00 ');
var second =parseint ((Wuyi.gettime ()-date.gettime ())/1000);
Var day =parseint (SECOND/3600/24);
var h = parseint (second/3600%24);
var min =parseint (second/60%60);
var s= parseint (second%60);
Day<10? ' 0 ' +day:day;
H<10?h= ' 0 ' +h:h;
min<10?min= ' 0 ' +min:min;
s<10?s= ' 0 ' +s:s;
txt.innerhtml = ' Distance 51 ' and ' +day+ ' Day ' +h+ ' hours ' +min+ ' +s+ ' seconds ';
}
}
</script>
<body>
<div id= "box" >
<p id= "TXT" ></p>
</div>
</body>
JS Timer Timing Device