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

老师授课-3-回答问题

时间:2016-05-25 20:33:07      阅读:116      评论:0      收藏:0      [点我收藏+]

标签:

 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 <title>无标题文档</title>
 6 
 7 </head>
 8 中国成立于哪一年?<input daan="1949" type="text" value="" id="qq" /><input type="button" value="确定" onclick="check()" /><br />
 9 
10 </body>
11 </html>
12 <script>
13 function check()
14 {
15     var a = document.getElementById("qq");
16     var a1 = a.value;
17     var a2 =a.getAttribute("daan");
18     if(a1==a2)
19     {
20         alert("答对了");    
21     }    
22     else
23     {
24         alert("笨蛋");    
25     }
26 }
27 </script>

运行

技术分享

输入的答案错误

技术分享技术分享

输入正确答案

技术分享技术分享

老师授课-3-回答问题

标签:

原文地址:http://www.cnblogs.com/tonyhere/p/5528257.html

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