How do we add a class to a cell (or any HTML element, for that matter)?įortunately, jQuery has a built-in solution with the addClass method. Space on the board, if a mine is inside of a space, then we’ll add a mineĬlass to the table cell associated with the space. Make things simple for right now, we’ll choose the CSS method. There are a couple ofĭifferent ways to do this, but ultimately we need to use HTML, CSS, or both. Since the game is all about revealing hidden mines, it seems that we ought to beĪble to draw those mines when the appropriate time comes. Now for something a little more interesting. Our minesweeper.js looks like this: const board = $("").attr("id", "board") įor (let columnIndex = 0 columnIndex ") Let’s review what we have in our project so far: Will allow us to update the board visually as the player interacts with the Generated via JavaScript when the page loads. In the last post we wrote code so that the visuals for Minesweeper are Building Minesweeper in JavaScript: Part 3
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |