We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1a9f958 commit d5fa8f2Copy full SHA for d5fa8f2
1 file changed
public/js/script.js
@@ -1,13 +1,26 @@
1
2
+var origBoard;
3
+const oPlayer = 'O';
4
const cells = document.querySelectorAll('.cell');
5
startGame();
6
7
function startGame() {
8
document.querySelector(".endgame").style.display = "none";
9
origBoard = Array.from(Array(9).keys());
10
+ console.log(origBoard);
11
for (var i = 0; i < cells.length; i++) {
- cells[i].innerText = '';
12
+ cells[i].innerText = ''; //clear
13
cells[i].style.removeProperty('background-color');
14
+ //add a event process vào click mouse event
15
cells[i].addEventListener('click', turnClick, false);
16
}
17
18
+
19
20
+function turnClick(square) {
21
+ // // write down the ID of any cell clicked
22
+ console.log(square.target.id)
23
24
+ // pass in the ID that clicking
25
+ turn(square.target.id,oPlayer)
26
+}
0 commit comments