码迷,mamicode.com
首页 > 其他好文 > 详细

时钟timer

时间:2016-05-31 19:09:14      阅读:166      评论:0      收藏:0      [点我收藏+]

标签:html   javascript   时钟   

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>timer</title>
<style type="text/css">
    .timetxt{
         /* Box-model盒子模型 */
        width: 300px;
        margin: 0 auto;
        margin-top: 150px;
        /* Typography排版 */
        font-size: 80px;
        font-weight: blod;
    }
</style>
</head>
<body onload="startTime()">
    <div class="timetxt" id="timetxt"></div>
</body>
<script type="text/javascript">
    function startTime(){
        var today = new Date();
        var h = today.getHours();
        var m = today.getMinutes();
        var s = today.getSeconds();
        m = checkTime(m);
        s = checkTime(s);
        document.getElementById(‘timetxt‘).innerHTML = h+‘:‘+m+‘:‘+s;
        t = setTimeout(startTime,1000);
    }

    function checkTime(i){
        if (i<10) {
            i = ‘0‘+i;
        }
        return i;
    }
</script>
</html>

时钟timer

标签:html   javascript   时钟   

原文地址:http://11254167.blog.51cto.com/11244167/1784960

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!