数码时钟
来源:互联网 发布:php web服务器搭建 编辑:程序博客网 时间:2024/06/10 18:07
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>数码时钟</title>
<script>
function toDou(n){
if(n<10){
return '0'+n;//空位补0
}
else{
return ''+n;
}
}
window.onload=function(){
var aImg=document.getElementsByTagName('img');
function tick(){
var oDate=new Date();
var str=toDou(oDate.getHours())+toDou(oDate.getMinutes())+toDou(oDate.getSeconds());
for( var i=0;i<aImg.length; i++){
//aImg[i].src='img/'+str[i]+'.png';
aImg[i].src='img/'+str.charAt(i)+'.png';
};
};
setInterval(tick,1000);
tick();
};
<body id="body_sm">
<img src="img/0.png" />
<img src="img/0.png" />
:
<img src="img/0.png" />
<img src="img/0.png" />
:
<img src="img/0.png" />
<img src="img/0.png" />
</body>
</html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>数码时钟</title>
<script>
function toDou(n){
if(n<10){
return '0'+n;//空位补0
}
else{
return ''+n;
}
}
window.onload=function(){
var aImg=document.getElementsByTagName('img');
function tick(){
var oDate=new Date();
var str=toDou(oDate.getHours())+toDou(oDate.getMinutes())+toDou(oDate.getSeconds());
for( var i=0;i<aImg.length; i++){
//aImg[i].src='img/'+str[i]+'.png';
aImg[i].src='img/'+str.charAt(i)+'.png';
};
};
setInterval(tick,1000);
tick();
};
</script>
<body id="body_sm">
<img src="img/0.png" />
<img src="img/0.png" />
:
<img src="img/0.png" />
<img src="img/0.png" />
:
<img src="img/0.png" />
<img src="img/0.png" />
</body>
</html>
0 0
- 数码时钟
- 数码时钟
- 数码时钟
- 数码时钟
- 数码时钟
- 数码时钟
- 数码时钟
- 数码时钟
- 简易数码时钟
- 定时器实现数码时钟
- js特效之数码时钟
- 定时器的实战--数码时钟
- 基于JavaScript的数码时钟
- 数码可调时钟(加闹钟)
- 定时器的应用(三):数码时钟
- JavaScript-定时器的使用之数码时钟
- javascript学习笔记9,10---定时器+数码时钟
- 一个超酷的数码时钟(走秒的)
- CMake命令之list
- 黑马程序员———单例模式
- XSS跨站测试代码大全
- 第十四周项目之oppo 电子词典
- google 字体开源
- 数码时钟
- Codeforces Round #301 (Div. 2) D(概率dp)
- HTML入门简介
- Kafka源码和文档阅读与体会(一)
- Socket send函数和recv函数详解
- C语言中const的用法
- [leetcode] Min Stack
- git 换行符问题,统一linux风格
- 黑马程序员——越过泛型机制