<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>猜拳游戏</title>
<style type="text/css">
#display1{
float: left;
}
#display2{
float: right;
margin-right: 302px;
}
#display3{
float: right;
margin-top: -200px;
}
#wanjiadisplay1{
float: left;
}
#wanjiadisplay2{
float: right;
margin-right: 302px;
}
#wanjiadisplay3{
float: right;
margin-top: -200px;
}
#wanjiadisplay31{
margin-left: 80px;
margin-top: 50px;
}
</style>
</head>
<body>
<div id="d" style="height: 550px; width: 700px; border: solid 1px; background-color: brown;">
<div id="display" style="height: 200px ;width: 700px; border: solid 1px;color: white;">
<div id="display1" style="height: 198px; width: 298px; border: solid 1px;">
<div style="margin-left: 120px;">你</div>
<div id="i2" style="margin-left: 100px; margin-top: 50px;"></div>
</div>
<div id="display2" style="height: 198px;width: 96px; border: solid 1px;">
<div style="font-size: 50px; color: black; margin-top: 80px; margin-left: 25px;">VS</div>
</div>
<div id="display3" style="height: 198px;width: 300px; border: solid 1px; ">
<div style="margin-left: 120px;">电脑</div>
<div id="i3" style="margin-left: 100px; margin-top: 50px;"></div>
</div>
</div>
<div style="width: 698px; height: 100px; border: solid 1px;color: white;">
<div id="result" style="margin-left: 300px; margin-top: 40px;">你赢了</div>
</div>
<div id="wanjiadisplay" style="width: 700px; height: 200px; border: solid 1px; color: white;">
<div id="wanjiadisplay1" style="height: 198px; width: 298px; border: solid 1px;">
<!-- <img src="" style="margin-top: 80px; margin-left: 100px;" id="i" /> -->
<div id="i" style="margin-left: 100px; margin-top: 70px;">石头</div>
</div>
<div id="wanjiadisplay2" style="height: 198px;width: 96px; border: solid 1px;">
</div>
<div id="wanjiadisplay3" style="height: 198px;width: 300px; border: solid 1px; ">
<div id="wanjiadisplay31" >
请选择出拳:
<span>
<select name="sel" id="sel" οnchange="show()">
<option value=""></option>
<option value="石头">石头</option>
<option value="剪刀">剪刀</option>
<option value="布">布</option>
</select>
</span>
<button type="button" id="selshow" style="margin-top: 10px;" οnclick="selshow1()" >选好了,出拳</button>
<button type="button" id="selshow()" οnclick="selshow2()" >重新选择</button>
</div>
</div>
</div>
<div id="showresult" style="width: 700px;height: 50px; border: solid 1px;color: white;">
<div style="margin-left: 250px;">
总局数:<span id="zongjushu"></span>赢:<span id="ying"></span>输:<span id="shu"></span>
<div/>
</div>
</div>
</body>
<script type="text/javascript">
var count=0;
var scount=0;
var fcount=0;
function autoshow(){
var i3=document.getElementById("i3");
var num=Math.random()*100;
num=Math.ceil(num);
num=num%3;
switch(num){
case 0:
i3.innerHTML="石头";
break;
case 1:
i3.innerHTML="剪刀";
break;
case 2:
i3.innerHTML="布";
break;
}
}
function selshow1(){
count++;
var s=document.getElementById("sel");
var choice=s.value;
var i=document.getElementById("i");
var i2=document.getElementById("i2");
var display=document.getElementById("result");
if(choice=="石头"){
i.innerHTML="石头";
i2.innerHTML="石头";
}else if(choice=="剪刀"){
i.innerHTML="剪刀";
i2.innerHTML="剪刀";
}else if(choice=="布"){
i2.innerHTML="布";
i.innerHTML="布";
}
//调用autoshow()函数,电脑随机出拳
autoshow();
var i3=document.getElementById("i3");
if(choice=="石头"&&i3.innerHTML=="剪刀"){
scount++;
display.innerHTML="你赢了";
}else if(choice=="剪刀"&&i3.innerHTML=="布"){
scount++;
display.innerHTML="你赢了";
}else if(choice=="布"&&i3.innerHTML=="石头"){
scount++;
display.innerHTML="你赢了";
}else if(choice==(i3.innerHTML)){
display.innerHTML="平局";
}else {
fcount++;
display.innerHTML="电脑赢了";
}
var zjs=document.getElementById("zongjushu");
zjs.innerHTML=count;
var y=document.getElementById("ying");
y.innerHTML=scount;
var s=document.getElementById("shu");
s.innerHTML=fcount;
}
function selshow2(){
var s=document.getElementById("sel");
s.value="";
}
</script>
</html>
<html>
<head>
<meta charset="UTF-8">
<title>猜拳游戏</title>
<style type="text/css">
#display1{
float: left;
}
#display2{
float: right;
margin-right: 302px;
}
#display3{
float: right;
margin-top: -200px;
}
#wanjiadisplay1{
float: left;
}
#wanjiadisplay2{
float: right;
margin-right: 302px;
}
#wanjiadisplay3{
float: right;
margin-top: -200px;
}
#wanjiadisplay31{
margin-left: 80px;
margin-top: 50px;
}
</style>
</head>
<body>
<div id="d" style="height: 550px; width: 700px; border: solid 1px; background-color: brown;">
<div id="display" style="height: 200px ;width: 700px; border: solid 1px;color: white;">
<div id="display1" style="height: 198px; width: 298px; border: solid 1px;">
<div style="margin-left: 120px;">你</div>
<div id="i2" style="margin-left: 100px; margin-top: 50px;"></div>
</div>
<div id="display2" style="height: 198px;width: 96px; border: solid 1px;">
<div style="font-size: 50px; color: black; margin-top: 80px; margin-left: 25px;">VS</div>
</div>
<div id="display3" style="height: 198px;width: 300px; border: solid 1px; ">
<div style="margin-left: 120px;">电脑</div>
<div id="i3" style="margin-left: 100px; margin-top: 50px;"></div>
</div>
</div>
<div style="width: 698px; height: 100px; border: solid 1px;color: white;">
<div id="result" style="margin-left: 300px; margin-top: 40px;">你赢了</div>
</div>
<div id="wanjiadisplay" style="width: 700px; height: 200px; border: solid 1px; color: white;">
<div id="wanjiadisplay1" style="height: 198px; width: 298px; border: solid 1px;">
<!-- <img src="" style="margin-top: 80px; margin-left: 100px;" id="i" /> -->
<div id="i" style="margin-left: 100px; margin-top: 70px;">石头</div>
</div>
<div id="wanjiadisplay2" style="height: 198px;width: 96px; border: solid 1px;">
</div>
<div id="wanjiadisplay3" style="height: 198px;width: 300px; border: solid 1px; ">
<div id="wanjiadisplay31" >
请选择出拳:
<span>
<select name="sel" id="sel" οnchange="show()">
<option value=""></option>
<option value="石头">石头</option>
<option value="剪刀">剪刀</option>
<option value="布">布</option>
</select>
</span>
<button type="button" id="selshow" style="margin-top: 10px;" οnclick="selshow1()" >选好了,出拳</button>
<button type="button" id="selshow()" οnclick="selshow2()" >重新选择</button>
</div>
</div>
</div>
<div id="showresult" style="width: 700px;height: 50px; border: solid 1px;color: white;">
<div style="margin-left: 250px;">
总局数:<span id="zongjushu"></span>赢:<span id="ying"></span>输:<span id="shu"></span>
<div/>
</div>
</div>
</body>
<script type="text/javascript">
var count=0;
var scount=0;
var fcount=0;
function autoshow(){
var i3=document.getElementById("i3");
var num=Math.random()*100;
num=Math.ceil(num);
num=num%3;
switch(num){
case 0:
i3.innerHTML="石头";
break;
case 1:
i3.innerHTML="剪刀";
break;
case 2:
i3.innerHTML="布";
break;
}
}
function selshow1(){
count++;
var s=document.getElementById("sel");
var choice=s.value;
var i=document.getElementById("i");
var i2=document.getElementById("i2");
var display=document.getElementById("result");
if(choice=="石头"){
i.innerHTML="石头";
i2.innerHTML="石头";
}else if(choice=="剪刀"){
i.innerHTML="剪刀";
i2.innerHTML="剪刀";
}else if(choice=="布"){
i2.innerHTML="布";
i.innerHTML="布";
}
//调用autoshow()函数,电脑随机出拳
autoshow();
var i3=document.getElementById("i3");
if(choice=="石头"&&i3.innerHTML=="剪刀"){
scount++;
display.innerHTML="你赢了";
}else if(choice=="剪刀"&&i3.innerHTML=="布"){
scount++;
display.innerHTML="你赢了";
}else if(choice=="布"&&i3.innerHTML=="石头"){
scount++;
display.innerHTML="你赢了";
}else if(choice==(i3.innerHTML)){
display.innerHTML="平局";
}else {
fcount++;
display.innerHTML="电脑赢了";
}
var zjs=document.getElementById("zongjushu");
zjs.innerHTML=count;
var y=document.getElementById("ying");
y.innerHTML=scount;
var s=document.getElementById("shu");
s.innerHTML=fcount;
}
function selshow2(){
var s=document.getElementById("sel");
s.value="";
}
</script>
</html>