File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11td {
2- border : 2px solid # 333 ;
3- height : 100px ;
4- width : 100px ;
5- text-align : center;
2+ border : 2px solid # 333 ;
3+ height : 100px ;
4+ width : 100px ;
5+ text-align : center;
66 vertical-align : middle;
7- font-family : "Comic Sans MS" , cursive, sans-serif;
8- font-size : 70px ;
9- cursor : pointer;
7+ font-family : "Comic Sans MS" , cursive, sans-serif;
8+ font-size : 70px ;
9+ cursor : pointer;
1010}
11- table {
11+
12+ table {
1213 border-collapse : collapse;
13- position : absolute;
14- left : 50% ;
15- margin-left : -155px ;
16- top : 50px ;
14+ position : absolute;
15+ left : 50% ;
16+ margin-left : -155px ;
17+ top : 50px ;
1718}
18- table tr : first-child td {
19+
20+ table tr : first-child td {
1921 /* border-top: 0; */
22+ }
23+
24+ .endgame {
25+ display : none;
26+ width : 200px ;
27+ top : 120px ;
28+ background-color : rgba (37 , 167 , 54 , 0.8 );
29+ position : absolute;
30+ left : 50% ;
31+ margin-left : -100px ;
32+ padding-top : 50px ;
33+ padding-bottom : 50px ;
34+ text-align : center;
35+ border-radius : 5px ;
36+ color : white;
37+ font-size : 2em ;
2038}
Original file line number Diff line number Diff line change 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 ++ ) {
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+ }
You can’t perform that action at this time.
0 commit comments