您好,登錄后才能下訂單哦!
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" >
<title></title>
</head>
<body onload="leftTimer()">
<h3>投標倒記時:</h3>
<table>
<tr>
<td id="days" ></td>
<td id="hours"></td>
<td id="minutes"></td>
<td id="seconds"></td>
</tr>
</table>
<style type="text/css">
td{ background: #1e7bb3; padding: 0 10px; height: 50px; line-height: 50px; font-size: 30px; color: #fff; font-weight: bold;}
</style>
</body>
</html>
<script language="javascript" type="text/javascript">
var itimer=null;
function checkTime(i){ //將0-9的數字前面加上0,例1變為01
if(i <1)
{
return "00";
}
else
{
if(i<10)
{
i = "0" + i;
}
return i;
}
}
function c(a)
{
console.log(a);
}
function leftTimer(year,month,day,hour,minute,second){
var leftTime = (new Date(year,month-1,day,hour,minute,second)) - (new Date()); //計算剩余的毫秒數
var days = parseInt(leftTime / 1000 / 60 / 60 / 24 , 10); //計算剩余的天數
var hours = parseInt(leftTime / 1000 / 60 / 60 % 24 , 10); //計算剩余的小時
var minutes = parseInt(leftTime / 1000 / 60 % 60, 10);//計算剩余的分鐘
var seconds = parseInt(leftTime / 1000 % 60, 10);//計算剩余的秒數
var seconds11=seconds;
days = checkTime(days);
hours = checkTime(hours);
minutes = checkTime(minutes);
seconds = checkTime(seconds);
document.getElementById("days").innerHTML = days+"天";
document.getElementById("hours").innerHTML = hours+"小時";
document.getElementById("minutes").innerHTML = minutes+"分";
document.getElementById("seconds").innerHTML = seconds+"秒";
//清除定時器任務
if(seconds11 < 0)
{
clearInterval(itimer);
}
c(leftTime);
}
window.onload = function(){
itimer= setInterval("leftTimer(2018,03,07,10,30,00)",1000);
}
</script>
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。