javascript数字时钟示例分享

时间:2014-04-23    点击:70   

代码很简单,直接上代码了,大家可以复制下面的代码保存成HTML文件运行看效果

复制代码 代码如下:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head></head>
<body>
<script language="javascript">
function Change(HourSurplus,MinuteSurplus,SecondSurplus)
{

 SecondSurplus = SecondSurplus - 1;
 if (SecondSurplus<0) 
 { 
 SecondSurplus=60+SecondSurplus; 
 MinuteSurplus=MinuteSurplus-1; 
 } 
 if (MinuteSurplus<0) 
 {  
 MinuteSurplus=60+MinuteSurplus; 
 HourSurplus=HourSurplus-1; 
 }
 document.getElementById("asd").innerHTML=""+ HourSurplus +":"+ MinuteSurplus +":"+ SecondSurplus +"";
 setTimeout(function() {
 Change(HourSurplus,MinuteSurplus,SecondSurplus);
 },1000);
}

</script>
<span id="asd">11111</span>
<script language="javascript">
Change(1,59,59);
</script>
</body>
</html>

JQuery为页面Dom元素绑定事件及解除绑定方法
JQuery下拉框应用示例介绍
JQuery对表格进行操作的常用技巧总结
IE6已终止操作问题的2种情况及解决
JS使用getComputedStyle()方法获取CSS属性值
> 返回     
地址:上海市普陀区胶州路941号长久商务中心 电话: QQ:
© Copyright 2012 上海网络 Product All Rights Reserved