各种倒计时JQUERY的解决DEMO,增正计时

作者: ldsea 分类: 程序生活 发布时间: 2012-05-18 23:37

[code lang=”js”]<!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>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>倒计时</title>
<script type="text/javascript" src="http://auto.sina.com.cn/683/2009/0901/jquery.js"></script>
</head>
<body>
<div class="daty"></div>
<div class="watch"></div>
<div class="djs"></div>
<script>
$(function(){
var timedate= new Date("2011/2/2");
var now = new Date();
var dates = timedate.getTime()-now.getTime();
var times =Math.abs(Math.floor(dates/(1000*60*60*24)));
jQuery(".daty").text("距离XX开幕还有"+times+"天");
})
$(function(){
function _fresh(){
var d2 = new Date();
d2.setHours(18,0,0,0)
var d0 = new Date();
var ts = (d2-d0)
__h=parseInt((ts/3600000)%24);
__m=parseInt((ts/60000)%60);
__s=parseInt((ts/1000)%60);
$(".watch").html("距离下班时间还有"+__h+"小时"+__m+"分"+__s+"秒")
var endtime=new Date("2012/01/19,12:20:12");
var xztime = new Date();
var ctime = parseInt((endtime.getTime()-xztime.getTime())/1000);
__d=parseInt(ctime/3600/24);
__h=parseInt((ctime/3600)%24);
__m=parseInt((ctime/60)%60);
__s=parseInt(ctime%60);
$(".djs").html("距离2012/2/2中午12:20:12还有"+__d+"天"+__h+"小时"+__m+"分"+__s+"秒")
}
_fresh()
var sh;
sh=setInterval(_fresh,1000);
})
</script>
</body>
</html>
[/code]

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注