⊗jsPrTTTTF 41 of 62 menu

Tic-tac-toe game in JavaScript

I believe that the essence of this game is known to everyone, so we will immediately begin to implement.

First, let's make the playing field in the form of a table <table>:

<table id="field"> <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>

Let's add some CSS code to make things look pretty:

#field td { width: 50px; height: 50px; border: 1px solid black; text-align: center; font-weight: bold; }

Get the cells of our table into a variable:

let cells = document.querySelectorAll('#field td');

Copy the following HTML, CSS and JavaScript codes for yourself.

enru