<!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>JS实现倒计时(时、分,秒)</title>
<script type="text/javascript" src="jquery-1.10.1.min.js"></script>
<script language="javascript" type="text/javascript">
window.οnlοad=function(){
var lefts=4*60*60;
var int=setInterval(clock,1000);
function clock(){
var hour=Math.floor((lefts)/3600);
var minute=Math.floor((lefts-hour*3600)/60);
var second=Math.floor(lefts-hour*3600-minute*60);
lefts=lefts-1;
$('#divdown1').html("活动结束还有:"+hour+"小时"+minute+"分"+second+"秒");
if(hour==0 && minute==0 && second==0){
window.clearInterval(int);
}
}
}
</script>
</head>
<body>
<div id="divdown1"></div>
</body>
</html>
倒计时4小时实现
最新推荐文章于 2023-04-21 11:17:32 发布