神马js都是浮云-----限时秒杀

来源:岁月联盟 编辑:exp 时间:2012-07-20
买了本js高级程序设计,看了一个多月仍然云里雾里的,盼望着盼望着终于开了js的课,涛哥一讲神马js全都浮云了,第一天的作业小小扩展了一下变成限时秒杀,图片上不了,自己复制下来看吧,时间仓促没有写暂停功能
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>倒计时-限时秒杀</title>
</head>
<body>
<p><input type="text" id="nid" name="some_name" value="" style="font-size:100px;width:1300px"></p>
</body>
<script type="text/javascript" charset="utf-8">
var mytime=60*60*60*24*10;
var nid=document.getElementById("nid");
var dd,hh,mm,ss,ms;
function fun(){
if(mytime>0){
mytime--;
}    www.2cto.com
dd=Math.floor(mytime/(60*60*60*24));
hh=Math.floor((mytime-(dd*60*60*60*24))/(60*60*60));
hh=(hh<10)?"0"+hh:hh;
mm=Math.floor((mytime-(dd*60*60*60*24)-(hh*60*60*60))/(60*60));
mm=(mm<10)?"0"+mm:mm;
ss=Math.floor((mytime-(dd*60*60*60*24)-(hh*60*60*60)-(mm*60*60))/60);
ss=(ss<10)?"0"+ss:ss;
ms=Math.floor((mytime-(dd*60*60*60*24)-(hh*60*60*60)-(mm*60*60)-(ss*60)));
ms=(ms<10)?"0"+ms:ms;
nid.value="限时秒杀:"+dd+"天"+hh+":"+mm+":"+ss+":"+ms;
}
setInterval("fun()",10);
</script>
</html>
作者:zdrjlamp