-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
74 lines (69 loc) · 2.64 KB
/
index.html
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Tic-Tac-Toe</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-eOJMYsd53ii+scO/bJGFsiCZc+5NDVN2yr8+0RDqr0Ql0h+rP48ckxlpbzKgwra6" crossorigin="anonymous">
<link rel="stylesheet" href="styles.css">
<script src="app.js"></script>
</head>
<body>
<script>
function play1(clicked_id){
let id = clicked_id;
document.getElementById(id).innerHTML = "X";
document.getElementById(id).setAttribute("data-value", "1")
whoIsTheWinner()
playO()
blockPlayerX()
///Block Overwrite
document.getElementById(id).setAttribute("onclick", null)
document.getElementById(id).setAttribute("class", "cube cd")
}
function play2(clicked_id){
let id1 = clicked_id;
document.getElementById(id1).innerHTML = "O";
document.getElementById(id1).setAttribute("data-value", "0")
whoIsTheWinner()
playX()
blockPlayerO()
document.getElementById(id1).disabled = true;
///Block Overwrite
document.getElementById(id1).setAttribute("onclick", null)
document.getElementById(id1).setAttribute("class", "cube cd")
}
</script>
<main>
<h4>Tic Tac Toe [X O]</h4>
<span id="winner"></span>
<!--row 1-->
<div class="row">
<div id="0" class="cube" onclick="isSelected()"></div>
<div id="1" class="cube" onclick="isSelected()"></div>
<div id="2" class="cube" onclick="isSelected()"></div>
</div>
<!--row 2-->
<div class="row">
<div id="3" class="cube" onclick="isSelected()"></div>
<div id="4" class="cube" onclick="isSelected()"></div>
<div id="5" class="cube" onclick="isSelected()"></div>
</div>
<!--row 3-->
<div class="row">
<div id="6" class="cube" onclick="isSelected()"></div>
<div id="7" class="cube" onclick="isSelected()"></div>
<div id="8" class="cube" onclick="isSelected()"></div>
</div>
<div class="players">
<button class="btn button1" onclick="playX()" id="player1">Player 1</button>
<button class="btn button2" onclick="playO()"id="player2">Player 2</button>
<button class="btn btn-success " onclick="history.go(0)">Reset</button>
</div>
</main>
<footer class="footer">
<p>© <a href="http://github.com/reboot13-git/tic-tac-toe" target="_blank" rel="noopener noreferrer">reboot13-git/tic-tac-toe</a></p>
</footer>
</body>
</html>