我的这段html倒计时代码怎么能改成到时间停止到0:0:0:0或显示活动已结束 求高手,解决加分
<!DOCTYPEhtml><html><head><metacharset="utf-8"/><title>商品秒杀倒计时</title><styletype="tex...
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>商品秒杀倒计时</title>
<style type="text/css">
#clock{
font:bold 24pt sans;
background-color: #f5f5f5;
padding: 10px 15px;
border: 1px solid #ccc;
border-radius: 5px;
}
</style>
</head>
<body>
<h1>商品秒杀倒计时</h1>
<span id="clock"></span>
<script>
function displayTime(){
var elt = document.getElementById("clock");
if(leftTime<0){
elt.innerHTML = "Over";
}
else{
var endTime = new Date("2015/04/15 18:45:13");
var now = new Date();
var leftTime = endTime.getTime() -now.getTime();
var ms = parseInt(leftTime%1000).toString();
leftTime = parseInt(leftTime/1000);
var o = Math.floor(leftTime / 3600);
var d = Math.floor(o/24);
var m = Math.floor(leftTime/60%60);
var s = leftTime%60;
elt.innerHTML = o + "小时:" + m + "分:" + s + "秒:" + ms.charAt(0);
setTimeout(displayTime,100);
}
}
displayTime();
</script> 展开
<html>
<head>
<meta charset="utf-8" />
<title>商品秒杀倒计时</title>
<style type="text/css">
#clock{
font:bold 24pt sans;
background-color: #f5f5f5;
padding: 10px 15px;
border: 1px solid #ccc;
border-radius: 5px;
}
</style>
</head>
<body>
<h1>商品秒杀倒计时</h1>
<span id="clock"></span>
<script>
function displayTime(){
var elt = document.getElementById("clock");
if(leftTime<0){
elt.innerHTML = "Over";
}
else{
var endTime = new Date("2015/04/15 18:45:13");
var now = new Date();
var leftTime = endTime.getTime() -now.getTime();
var ms = parseInt(leftTime%1000).toString();
leftTime = parseInt(leftTime/1000);
var o = Math.floor(leftTime / 3600);
var d = Math.floor(o/24);
var m = Math.floor(leftTime/60%60);
var s = leftTime%60;
elt.innerHTML = o + "小时:" + m + "分:" + s + "秒:" + ms.charAt(0);
setTimeout(displayTime,100);
}
}
displayTime();
</script> 展开
展开全部
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>商品秒杀倒计时</title>
<style type="text/css">
#clock{
font:bold 24pt sans;
background-color: #f5f5f5;
padding: 10px 15px;
border: 1px solid #ccc;
border-radius: 5px;
}
</style>
</head>
<body>
<h1>商品秒杀倒计时</h1>
<span id="clock"></span>
<script>
function displayTime(){
var elt = document.getElementById("clock");
if(leftTime<0){
elt.innerHTML = "Over";
}
else{
var endTime = new Date("2015/04/15 11:46:30");
var now = new Date();
var leftTime = endTime.getTime() -now.getTime();
var ms = parseInt(leftTime%1000).toString();
leftTime = parseInt(leftTime/1000);
var o = Math.floor(leftTime / 3600);
var d = Math.floor(o/24);
var m = Math.floor(leftTime/60%60);
var s = leftTime%60;
elt.innerHTML = o + "小时:" + m + "分:" + s + "秒:" + ms.charAt(0);
if(s<0){document.getElementById('clock').innerHTML='活动结束!';return;};
setTimeout(displayTime,100);
}
}
displayTime();
</script>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询