5.25 问答练习

 1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 2 <html xmlns="http://www.w3.org/1999/xhtml">
 3 <head>
 4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 5 
 6 <title>5.25  姓名问答练习</title>
 7 </head>
 8 
 9 <body>
10 <form>
11 你叫什么名字?
12 <input type="text" value="" mingzi="岁月静好" id="1" />
13 <input type="button" value="检查" id="2" onclick="check()" />
14 </form>
15 </body>
16 </html>
17 <script>
18 function check()
19 {
20 var a=document.getElementById("1");
21 var b=a.value;
22 var c=a.getAttribute("mingzi");
23 if(b==c)
24 {
25 alert("回答正确");
26 }    
27 else
28 {
29 alert("回答错误")    ;
30 }
31 }
32 </script>
原文地址:https://www.cnblogs.com/suiyuejinghao123/p/5536391.html