zoukankan      html  css  js  c++  java
  • 自动重复调用函数,去除属性

    1 <body>
    2 
    3 年份:<input type="text"  id="A" shx="2016" /><br />
    4 <input type="button" value="提交"  onclick="tj()" /><br />
    5 
    6 例子2:
    7 <input type="button" value="同意么?(10)" id="B" disabled="disabled"  />
    8 
    9 </body>
     1 <script >
     2 function tj()
     3 {
     4     var a = document.getElementById("A");
     5     var a1 = a.value;
     6     var a2 = a.getAttribute("shx");
     7     if(a1 == a2)
     8     {
     9         alert("回答正确")
    10     }
    11     else
    12     {
    13         alert("错误回答")
    14     }
    15 }
    16 
    17 var b = document.getElementById("B");
    18 var n = 10;
    19 function sx()
    20 {
    21     n--;
    22     if(n==0)
    23     {
    24         b.removeAttribute("disabled");
    25         b.value="同意";
    26         return;
    27     }
    28     else
    29     {
    30         b.value = "同意么?("+n+")";    
    31     }
    32     window.setTimeout("sx()",1000);
    33 }
    34 window.setTimeout("sx()",1000);
    35 
    36 </script>
     window.setTimeout("sx()",1000); 
    每隔 1 秒,自动调用一次 sx() 函数
    结果:







  • 相关阅读:
    git
    redis
    Hexo-butterfly-magicv3.0.1(持续更新中....)
    转发好文章1
    0x07 Nagios Notifications
    0x06 nagios监控状态
    0x05 Nagios Host Check
    0x03 Nagios Plugins介绍
    0x02 Nagios CGI的认证和授权
    0x01 Nagios配置文件
  • 原文地址:https://www.cnblogs.com/wanlibingfeng/p/5622910.html
Copyright © 2011-2022 走看看