数字采用漂亮的糖果皮肤设计
效果图:
代码如下:
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta content="width=device-width, initial-scale=1" /> <title>js多彩的数字时钟_何问起</title><base target="_blank" /> <style>a{color:blue;}</style> </head> <body> <div><h1>JS实现多彩的数字时钟</h1></div> <div></div> <div><br /><br /><a href="https://hovertree.com">何问起</a> <a href="https://hovertree.com/h/bjaf/o0yqj1ly.htm">说明</a> <a href="https://hovertree.com/texiao/">特效</a></div> <script> function getTime(){ var date = new Date(); var hours =formatTime(date.getHours()); var minutes = formatTime(date.getMinutes()); var seconds = formatTime(date.getSeconds()); var $time = document.getElementById('time'); $time.innerHTML=hours +"<img src='https://www.jb51.net/images/hm.png'/>"+ minutes+"<img src='https://www.jb51.net/images/ms.png'/>"+ seconds; setTimeout("getTime()",500); } function formatTime(i){ if(i<10&&i==1){ i= "<img src='https://www.jb51.net/images/0.png'/>"+"<img src='https://www.jb51.net/images/1.png'/>"; }else if(i<10&&i!=1){ i= "<img src='https://www.jb51.net/images/0.png'/>" + "<img src='images/"+i+".png'/>"; }else{ var j= i.toString().charAt(0); var z =i.toString().charAt(1); if(j<10 && z<10&&j!=1&&z!=1){ i = "<img src='images/"+j+".png'/>" + "<img src='images/"+z+".png'/>"; }else if(j<10 && z<10&&j==1&&z!=1){ i = "<img src='https://www.jb51.net/images/1.png'/>" + "<img src='images/"+z+".png'/>"; }else if(j<10 && z<10&&z==1&&j!=1){ i = "<img src='images/"+j+".png'/>"+"<img src='https://www.jb51.net/images/1.png'/>"; }else if(j<10 && z<10&&(j==1&&z==1)){ i="<img src='https://www.jb51.net/images/1.png'/>"+"<img src='https://www.jb51.net/images/1.png'/>"; } } return i; } getTime(); </script> </body> </html>
以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,同时也希望多多支持脚本之家!
您可能感兴趣的文章: