首页 > 其他 > 详细

简易秒表

时间:2015-05-05 10:11:41      阅读:153      评论:0      收藏:0      [点我收藏+]
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="author" content="智能社 - zhinengshe.com" />
<meta name="copyright" content="智能社 - zhinengshe.com" />
<title>智能社 - www.zhinengshe.com</title>

<script>

function addZero(n){
    if(n < 10){
      return "0" + n;
    } else {
      return "" + n;
    }
}

window.onload = function(){
    
    var aInput = document.getElementsByTagName("input");
    
    var timer = null;
    
    var bClick = false;//没有被点击
    var i = 0;
    // 秒转 分钟  秒
    aInput[1].onclick = function(){

        if(bClick == false){
            bClick =true;
            clearInterval(timer);
            timer=setInterval(function(){
                i++;
                aInput[0].value =addZero(parseInt(i/60))+ ":"+addZero(i%60);
            },100);
        }
    };
    

    aInput[aInput.length -1].onclick =function(){
        clearInterval(timer);
        bClick =false
    }
};



</script>
</head>

<body>

<input type="text" value="00:00" />
<input type="button" value="计时" />
<input type="button" value="暂停" />

</body>
</html>

技术分享

简易秒表

原文:http://www.cnblogs.com/heboliufengjie/p/4478360.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!