做一个问题,如果输入的答案正确则弹出正确,错误弹出错误

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>

<body>
<form>
中华民国成立于哪一年?<input type="text" daan="1912年" value="" id="t1" name="t1" /><input type="button" onclick="check()" id="t2" name="t2" value="检查答案" />
</form>
</body>
</html>
<script>
function check()
{
    var a=document.getElementById("t1");
    var a1=a.value;
    var b=a.getAttribute("daan");
    if(a1==b)
    {
        alert("恭喜你答对了")}
        else
        {
            alert("笨蛋!")
            }    
}
</script>
View Code

posted @ 2016-03-26 16:32  1011042043  阅读(244)  评论(0编辑  收藏  举报