<script type="text/javascript"> var shu = 0; var jishi = 0; var jieguo=document.getElementById("jg"); function bian(){ shu = parseInt(Math.random()*3 )+1; document.getElementById("p").src="img/"+shu+".png"; jishi = window.setTimeout("bian()",200) } function iswin(num){ window.clearTimeout(jishi); if(num == shu){ jieguo.value="平局"; }else if(num==1&&shu==3||num==2&&shu==1||num==3&&shu==2){ jieguo.value="赢了"; }else{ jieguo.value="输了"; } } </script> </head> <body> <table align="center"> <tr align="center"> <td><img src="img/1.png"/ width="200" height="250" id="p" /></td> </tr> <tr align="center"> <td><input type="button" value="开始" onclick="bian()"/> </td> </tr> <tr align="center"> <td> <input id="dian1" type="button" value="石头" onclick="iswin(2)"/> <input id="dian2" type="button" value="布" onclick="iswin(3)"/> <input id="dian3" type="button" value="剪刀" onclick="iswin(1)"/> </td> </tr> <tr> <td><input id="jg" type="text" /> </td> </tr> </table>
3 回答
慕粉13727861792
TA贡献4条经验 获得超0个赞
<input id='a' type='text'/>
var a=document.getElementById('a');
a.innerHTML=jieguo;
可以试试
添加回答
举报
0/150
提交
取消