js倒计时事例

  |   0 评论   |   981 浏览

From Evernote:

js倒计时事例

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
  <TITLE> New Document </TITLE>
  <META NAME="Generator" CONTENT="EditPlus">
  <META NAME="Author" CONTENT="">
  <META NAME="Keywords" CONTENT="">
  <META NAME="Description" CONTENT="">

  <script type="text/javascript">
          function sub(){
               if(confirm('确认是否提交?')){
                    var s1 = document.getElementById("s1");
                    s1.disabled = true;
                    changeNum();
               }
          }
         
          var retime = 5;
          function changeNum(){
               if(retime>0){
                    var s1 = document.getElementById("s1");
                    s1.value = "s1("+(retime--)+")";
                    setTimeout(changeNum,1000);    
               }else{
                    var s1 = document.getElementById("s1");
                    s1.value = "s1";
                    s1.disabled = false;
               }
          }
     </script>

</HEAD>

<BODY>
                 
    <form action="" method="post"">
    <input type="text" name="amount">
    <input type="button" name="s1" value="s1" id="s1" onclick="sub()" >
    </form>
</BODY>
</HTML>




评论

发表评论

validate