美文网首页
js实现倒计时

js实现倒计时

作者: ml66 | 来源:发表于2016-09-07 10:06 被阅读0次

<!DOCTYPE html>
<html>
<title>Web Page Design</title>
<head>
<script src="script.js"></script>
</head>
<body>
<div id="starttext" onclick="passStart()"></div>
</body>
</html>

//倒计时3秒,然后弹出Hello,word!
var timeleft =3;
var int=self.setInterval("passStart()",1000);
function passStart()
{
     console.log(timeleft)
    
          if(timeleft===-1){
             sayHello ();
          }else{
           document.getElementById('starttext').innerHTML='跳过('+timeleft+')';
           --timeleft;
          }
          
}
function sayHello(){
    alert("Hello,word!");
}

相关文章

网友评论

      本文标题:js实现倒计时

      本文链接:https://www.haomeiwen.com/subject/lddjettx.html