Introduction
In this article, I will explain clearly and briefly how to use HTML, JavaScript, jQuery, and CSS in building a reordering random numbers game (1,2,3,4,5,6,7,8).
Building such games depends on your logic.
You can find all the related files (codes) on the attachment.
The game will look like the following,


First, we should build the structure of the UI, so before doing anything create a table and for every td specify its siblings by using a custom attribute data-sibling,
- <table>
- <tr>
- <td data-sibling="2and4" Id="td1"></td>
- <td data-sibling="1and3and5" Id="td2"></td>
- <td data-sibling="2and6" Id="td3"></td>
- </tr>
- <tr>
- <td data-sibling="1and5and7" Id="td4"></td>
- <td data-sibling="2and4and6and8" Id="td5"></td>
- <td data-sibling="3and5and9" Id="td6"></td>
- </tr>
- <tr>
- <td data-sibling="4and8" Id="td7"></td>
- <td data-sibling="5and7and9" Id="td8"></td>
- <td data-sibling="6and8" Id="td9"></td>
- </tr>
- </table>
Then move to apply CSS to get the target UI, you can find the full CSS code with attached files.
- table {
- background-color: #403737;
- color: #fffffe;
- cursor: pointer;
- border-radius: 5px;
- width: 100%;
- margin: 0px auto;
- float: none;
- border:10px solid #5a545a;
- margin :20px;
- }
- table tr td {
- border: 5px solid #5a545a;
- width: 100px;
- height: 100px;
- text-align: center;
- font-size: 20px;
- font-weight: bold;
- }

Join the conversation! Your thoughts help the community grow.