首页 > 其他 > 详细

最简单的实现倒计时

时间:2014-04-11 00:22:04      阅读:513      评论:0      收藏:0      [点我收藏+]

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf8" />
<title>倒计时</title>
</head>
<body>
<div id="times"></div>
<script type="text/javascript">
function _fresh()
{
var endtime=new Date("2015-01-01");//这里设置预制时间
var nowtime = new Date();
var leftsecond=parseInt((endtime.getTime()-nowtime.getTime())/1000);
if(leftsecond<0){leftsecond=0;}
__d=parseInt(leftsecond/3600/24);
__h=parseInt((leftsecond/3600)%24);
__m=parseInt((leftsecond/60)%60);
__s=parseInt(leftsecond%60);
document.getElementById("times").innerHTML=__d+"天 "+__h+"小时"+__m+"分"+__s+"秒";
}
_fresh()
setInterval(_fresh,1000);
</script>
</body>
</html>

最简单的实现倒计时,布布扣,bubuko.com

最简单的实现倒计时

原文:http://www.cnblogs.com/xffy1028/p/3656402.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!