DIV CSS 佈局教程網

 DIV+CSS佈局教程網 >> 網頁腳本 >> WEB網站前端 >> 網頁特效代碼 >> JS實現多彩漂亮的數字時鐘
JS實現多彩漂亮的數字時鐘
編輯:網頁特效代碼     

效果展示:
http://hovertree.com/texiao/js/35/

數字采用漂亮的糖果皮膚設計

末尾附有源代碼下載

效果圖:


代碼如下:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" 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 id="time"></div>
<div><br /><br /><a href="http://hovertree.com">何問起</a> <a href="http://hovertree.com/h/bjaf/o0yqj1ly.htm">說明</a> <a href="http://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='images/hm.png' style='margin:0 10px;' width='12' height='40'/>"+ minutes+"<img style='margin:0 10px;' src='images/ms.png' width='12' height='40'/>"+ seconds;

setTimeout("getTime()",500);

}
function formatTime(i){
if(i<10&&i==1){
i= "<img src='images/0.png' width='40' height='60'/>"+"<img src='images/1.png' width='20' height='60'/>";
}else if(i<10&&i!=1){
i= "<img src='images/0.png' width='40' height='60'/>" + "<img src='images/"+i+".png' width='40' height='60'/>";
}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' width='40' height='60'/>" + "<img src='images/"+z+".png' width='40' height='60'/>";
}else if(j<10 && z<10&&j==1&&z!=1){

i = "<img src='images/1.png' width='20' height='60'/>" + "<img src='images/"+z+".png' width='40' height='60'/>";

}else if(j<10 && z<10&&z==1&&j!=1){
i = "<img src='images/"+j+".png' width='40' height='60'/>"+"<img src='images/1.png' width='20' height='60'/>";

}else if(j<10 && z<10&&(j==1&&z==1)){
i="<img src='images/1.png' width='20' height='60'/>"+"<img src='images/1.png' width='20' height='60'/>";
}
}

return i;
}
getTime();
</script>
</body>
</html>

源碼下載:http://hovertree.com/h/bjaf/1bjk6acq.htm
XML學習教程| jQuery入門知識| AJAX入門| Dreamweaver教程| Fireworks入門知識| SEO技巧| SEO優化集錦|
Copyright © DIV+CSS佈局教程網 All Rights Reserved