- Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathjq.html
More file actions
Latest commit
60 lines (58 loc) · 1.89 KB
/
Copy pathjq.html
File metadata and controls
60 lines (58 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<!DOCTYPE html>
<html>
<head>
<metacharset="UTF-8"/>
<title>じゃんけん</title>
<scriptsrc="http://code.jquery.com/jquery-2.0.3.min.js"></script>
<scripttype="text/javascript">
varintervalId;
varcomputer;
functionroll()
{
varimg={
1: 'stone.png',2: 'cissor.png',3: 'paper.png',
};
computer=Math.floor(Math.random()*3)+1;
$('#computer').attr('src',img[computer])
.attr('alt',img[computer]);
}
functionpong(hand)
{
clearInterval(intervalId);
intervalId=null;
varmsg;
if(computer==hand){
msg='あいこ';
}elseif(computer==1&&hand==3
||computer==2&&hand==1
||computer==3&&hand==2){
msg='あなたの勝ち!';
}else{
msg='あなたの負け';
}
$('#status').text(msg+'(ここをクリックでもう一度)');
}
functionstart()
{
if(intervalId){
return;
}
$('#status').text('じゃーんけん');
roll();
intervalId=setInterval(roll,100);
}
$(start);
</script>
</head>
<body>
<div>
<imgid="computer" src="stone.png" alt="stone.png"/>
</div>
<divid="status" onclick="start();"></div>
<div>
<imgsrc="stone.png" onclick="pong(1)"/>
<imgsrc="cissor.png" onclick="pong(2);"/>
<imgsrc="paper.png" onclick="pong(3);"/>
</div>
</body>
</html>