放学了倒计时
<script type="text/javascript">
function task(){
var now=new Date();
var end=new Date('2018/5/25 18:00');
var s=(end-now)/1000;
if(s>0){
var h=Math.floor(s/3600);
var m=Math.floor(s%3600/60);
s=Math.floor(s%60);
document.querySelector('span').innerHTML=h+'小时'+m+'分钟'+s+'秒';
}else{
clearInterval(timer);
document.querySelector('span').innerHTML='放学了';
}
}
task();
var timer=setInterval(task,1000);
function stop(btn){
if(btn.innerHTML=="||"){
clearInterval(timer)
btn.innerHTML="|>";
}else{
timer=setInterval(task,1000);
btn.innerHTML="||";
}
}
</script>
。