js求助。。。
哪错了,执行没反应
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8"/><title>猜数字</title>
<script>
window.onload=function(){
var txt=document.getElementById("in");
var submit=document.getElementById("submit");
var reset=document.getElementById("reset");
var retry=document.getElementById("retry");
var pd=document.getElementById("pd");
var i=0;
var num = Math.floor(Math.random() * 100 + 1);
}
submit.onclick=function(){
if(++i<=10){
var content=txt.value;
if(!isNaN(content)){
pd.innerHTML="请输入数字";
}
else{
if(content<num){
pd.innerHTML="有点小。。。";
txt.focus();
}
else if(content==num){
pd.innerHTML="恭喜你,猜对啦";
submit.disabled=TRUE;
reset.disabled=TRUE;
}
else{
pd.innerHTML="有点大。。。";
txt.focus();
}
}
}
else{
alert("你已经没机会了");
submit.disabled=TRUE;
reset.disabled=TRUE;
}
}
reset.onclick=function(){
txt.value="";
}
retry.onclick=function(){
i=0;
var num = Math.floor(Math.random() * 100 + 1);
}
</script>
</head>
<body>
输入一个1--100之间的整数:<br/><input type="number" id="in"/><p id="pd"></p><br/><input type="button" id="submit" value="确定"/>
<input type="button" id="reset" value="重置"/><input type="button" id="retry" value="重新开始"/>
</body>
</HTML>