代码如下:
<html>
<head>
<title>一款js动态数字时钟丨站长技术教程网</title>
<style type="text/css">
body{
font:bolder 20px 微软雅黑;
}
</style>
<script type="text/javascript">
window.onload = function(){
var spans = document.getElementsByTagName("span");
function upDate(){
var date = new Date();
for(var i = 0; i<spans.length;i++){
var str=toDouble(date.getHours())+toDouble(date.getMinutes())+toDouble(date.getSeconds());
spans[i].innerHTML = str.charAt(i);
}
}
setInterval(upDate,1000);
upDate();
}
function toDouble(number){
if(number <10){
return "0"+number;
}
else return ""+number;
}
</script>
</head>
<body>
<span>0</span>
<span>0</span>点
<span>0</span>
<span>0</span>分
<span>0</span>
<span>0</span>秒
</body>
</html>
中国足彩网信息请查看IT技术专栏