디지털 시계

1349 단어
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title></title>
    <style>
        body{font-size: 50px;background: #e322ff;color: #fff756}
    </style>
</head>
<body>
<span></span>
<span></span>
<span></span>
<span></span>
 
<span></span>
<span></span>
 
<span></span>
<span></span>
 
<span></span>
<span></span>
 
<span></span>
<span></span>
 
<span></span>
<span></span>
 
<script>
//     
    function todouble(num){
        if(num<10){
            return "0"+num;
        }else{
            return ""+num;
        }
    }
// 
    function toUpdatetime(){
        var ospan=document.getElementsByTagName("span");
        var odate=new Date();
        var str=''+odate.getFullYear()+todouble((odate.getMonth()+1))+todouble(odate.getDate())+todouble(odate.getHours())+todouble(odate.getMinutes())+todouble(odate.getSeconds());
        for(var i=0;i<ospan.length;i++){
            ospan[i].innerHTML=str.charAt(i);
        }
    }
    toUpdatetime();
    setInterval(toUpdatetime,1000);
</script>
</body>
</html>

좋은 웹페이지 즐겨찾기