码迷,mamicode.com
首页 > 其他好文 > 详细

例子:倒计时按钮可用

时间:2016-09-26 14:46:19      阅读:120      评论:0      收藏:0      [点我收藏+]

标签:

<div style="width:500px; height:500px; margin:100px 0px 0px 100px">

<input id="btn" type="submit" value="确定" style="width:100px; height:35px" disabled="disabled" />

<span id="daojishi">10</span>

<div style="margin-top:20px">  

  <span id="h"></span>    

  <span id="m"></span>    

  <span id="s"></span> </div>

</div>

 

 

<script type="text/javascript">

window.setTimeout("YanChi()",1000);

function YanChi()

{  

  var span = document.getElementById("daojishi");    

  //改变span里面的值  

  span.innerText = span.innerText-1;    

  //判断是否减到了0

   if(span.innerText == 0)

   {   

    document.getElementById("btn").removeAttribute("disabled");   

    return;

   }  

   window.setTimeout("YanChi()",1000);  

}

window.setInterval("Bian()",1000);

 

 

function Bian()

{  

  var sj = new Date();      

  document.getElementById("h").innerText = sj.getHours();  

  document.getElementById("m").innerText = sj.getMinutes();  

  document.getElementById("s").innerText = sj.getSeconds();  

}

</script>

例子:倒计时按钮可用

标签:

原文地址:http://www.cnblogs.com/l5580/p/5909030.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!