<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<table>
<tr>
<td><input type="text" id="num" /></td>
<td><button οnclick="guess()">猜</button></td>
<td>
<span id="result">=</span>
</td>
</tr>
</table>
<script type="text/javascript">
var random = parseInt(Math.random() * 100 + 1);
function guess(){
var numb = document.getElementById('num').value;
while(true){
if(random<numb){
document.getElementById('result').innerHTML= "猜大了";
} else if(random>numb){
document.getElementById('result').innerHTML= "猜小了";
} else{
document.getElementById('result').innerHTML= "猜对了";
break;
}
document.getElementById('result').innerHTML = '=' + resultObj.value;
}
}
</script>
</body>
<!-- 1、写完语句下分号
2、-->
</html>
html制作猜大小游戏
最新推荐文章于 2023-10-27 10:21:08 发布