<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Document</title>
<style>
div{
width:800px;
height:200px;
/* border:1px solid red; */
margin:0 auto;
}
span{
font-size:30px;
color:red;
}
a{
width:100px;
height:30px;
font-size:30px;
}
</style>
</head>
<div>
<span id="qiang"></span>
<a id="as" href="javascript:">开抢</a>
<span id="ke"></span>
</div>
<body>
<script>
var qiang = document.getElementById('qiang');
var as = document.getElementById('as');
var ke = document.getElementById('ke');
function rem(){
var d = new Date();
var w = new Date('2016/17/14 19:50:50');
var x = w.getTime()-d.getTime();
if (x<0){
return '000天00时00分00秒';
}
var t = Math.floor(x/1000/60/60/24);
var s = Math.floor(x/1000/60/60)%24;
var f = Math.floor(x/1000/60)%60;
var m = Math.floor(x/1000)%60;
var str =t+'天'+s+'时'+f+'分'+m+'秒';
// var i ='0';
// if(m<10){
// str =t+'天'+s+'时'+f+'分'+i+m+'秒';
// }else{
// i='';
// str =t+'天'+s+'时'+f+'分'+i+m+'秒';
// }
return str
// console.log(str);
}
rem();
var tim;
var s = setInterval(function(){
qiang.innerHTML=rem();
if(qiang.innerHTML=='000天00时00分00秒'){
clearInterval(s);
qiang.style.display='none';
as.style.color='red';
as.setAttribute('href','1-1.html');
as.onclick=null;
}
},1000);
as.onclick=function(){
ke.innerHTML='客关别急还没到时间!';
tim=setTimeout(function(){
ke.innerHTML=null;
},2000)
}
</script>
</body>
</html>
杰杰就是我
相关分类