两个小练习

 1 <body>
 2 <form>
 3     <input type="text" id="a1" daan="1949"  />
 4     <input type="button" value="提交" onclick="aa()" />
 5     <input type="button" value="同意10" id="a2" disabled="disabled" />
 6 </form>
 7 </body>
 8 </html>
 9 <script>
10 function aa()
11 {
12     var a = document.getElementById("a1");
13     var b = a.getAttribute("daan");
14     var c = a.value;
15     if(b==c)
16     {
17         alert("正确");
18     }
19     else
20     {
21         alert("错误");
22     }
23 }
24 var n = 10;
25 function aaa()
26 {
27     var a = document.getElementById("a2");    
28     n--;
29     if(n == 0)
30     {
31         a.value = "同意";
32         a.removeAttribute("disabled");
33     }
34     else
35     {
36         a.value = "同意" + n;
37         window.setTimeout("aaa()",1000); 
38     }
39 }
40 window.setTimeout("aaa()",1000);
41 </script>

第一个是对比答案是否正确,第二个是倒计时。

posted on 2016-05-25 21:49  马MZJ  阅读(319)  评论(0编辑  收藏  举报