<! DOCTYPE html>
<mata charset = "Utf-8"/>
<title> hit the ground mouse </title>
<style>
#tb {
Background:url (beijing.jpg) no-repeat;
}
#fen {
Font-weight:bold;
font-size:60px;
Font-family: mini simple haha;
}
#fen1 {
Font-weight:bold;
font-size:60px;
Font-family: mini simple haha;
}
</style>
<script>
function Kaishi () {
SetTimeout ("BH ()", 3000);
sum=0;
}
To achieve the action of the Hamster
function bh () {
Sj=math.floor (Math.random () *9);
Img1=document.getelementsbytagname ("img");
Img1[sj].src= "Dishu.gif";
Add a click event and strike action to a hamster picture
Img1[sj].setattribute ("onclick", "Daji ()");
SetTimeout ("xs ()", 1000);
}
To achieve the action of hitting the hamster, change the hamster picture to hit the picture, and remove the onclick event, to avoid the occurrence of a hamster hit two times, plus two times the condition of the score
function Daji () {
Img1[sj].src= "Shang.gif";
Img1[sj].removeattribute ("onclick");
Replace the image integrator plus a very
sum+=10;
Changing the Integrator
document.getElementById ("Fen"). INNERHTML=SUM/10;
document.getElementById ("Fen1"). Innerhtml=sum;
}
A second later, the gopher disappeared.
function xs () {
Img1[sj].removeattribute ("onclick");
Img1[sj].src= "Keng.gif";
SetTimeout ("BH ()", 1000);
}
</script>
<body onload= "Kaishi ()" >
<center>
<table id= "TB" >
<foction> hit the ground mouse </foction>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
</table>
<p id= "Fen" > Hit Count </p>
<p id= "Fen1" > Score </p>
</center>
</body>
JS in the game to play the Gopher