html+js 猜数游戏

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>

<body>
<script>
    function start()
    {
        var num=Math.round(Math.random()*10);
        if(num==document.getElementById("t1").value)
        {
            document.write("恭喜您,猜对了,真棒!");
        }
        else
        {
            document.write("很抱歉,您猜错了! ");
        }
    }
</script>
请猜想一个0-10之间的数字:
<input type="text" id="t1" name="框" value="">
<button id="b1" name="提交" value="" onClick="start()">提交</button>
</body>
</html>
0

Leave a Reply

Your email address will not be published.