js ---------- Digital Alarm Clock

Renderings:

code:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>选项卡</title>
    <style>
 </style>
    <script>

window.onload=function () {
    function toDouble(num) {
        if (num<10){
            return '0'A;+
        }
        else {
            return ''+num;
        }
    }
    var oBtn=document.getElementById('btn');

    var  Img=document.getElementsByTagName('img');
    function update() {
     var oDate=new Date();
     var str=toDouble(oDate.getHours())+toDouble(oDate.getMinutes())+toDouble(oDate.getSeconds());

     for (i=0; I < Img.length; I ++ ) { 
         the Img [I] .src = ' ../IMG/ ' + str.charAt (I) + ' .png ' ; 
     } 
    } 
    the setInterval (Update, 1000 ); // not after you open the timer, direct execution, but the need to over 1000 ms, the following line of code to solve 
    // after the first turn on the timer function is executed manually, you can solve this problem; 
    Update (); 
} 
    </ Script > 
</ head > 
< body style = "background: # 990099; Color: # FFFF00; font-size: 50px" > 

< IMG the src="../IMG/0.png" alt="">
<img src="../IMG/0.png" alt=""><img src="../IMG/0.png" alt="">
<img src="../IMG/0.png" alt=""><img src="../IMG/0.png" alt="">
<img src="../IMG/0.png" alt=""></body>
</html>

 

Guess you like

Origin www.cnblogs.com/1322957664qqcom/p/11297793.html