Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8827657
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T07:25:26+00:00 2026-06-14T07:25:26+00:00

I have a very simple JavaScript tic-tac-toe game which appears to be running well

  • 0

I have a very simple JavaScript tic-tac-toe game which appears to be running well currently. It consists of an array which holds X’s and O’s, will not allow the same spot selection twice, and the computer turn is based off a random number generated which is still open in the array.

My only issues left are what to do when a winner is declared (computer or human).

At that point, I will need to end the JavaScript running the game until the user chooses to reset the board and start again.

This entails two details that I am struggling with:

  1. I need the sectors of the tic-tac-toe board to become "unclickable" or to not register anymore clicks once the winner is declared. Currently even after a game is decided to be won or lost, if there are empty spaces left over then the user can continue to mark those spaces on the board.

  2. Solving the above should help in part to solve this problem, but it might also be nice to completely stop the game overall once the game’s winner is declared. Currently, again because the user can continue clicking open spaces if they exist, the counter (which counts wins for the user) will continue to increment as long as there exists a win on the board. Again though, by solving problem 1, transitively solve this problem as well since the clicks don’t work and thereby the counter will not be incremented.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T07:25:27+00:00Added an answer on June 14, 2026 at 7:25 am

    If ending the game is simply a matter of making the squares not respond to clicks, then you could just create a function that binds to the click event for the boxes.

    For example, if each box is an link with a class of “box”, then you could do:

    var boxes = document.getElementsByClassName('box');
    for(var key in boxes) { 
      boxes[key].onclick = function(e) {
      e.preventDefault();
    }
    

    Or, using jQuery

    $(document).on("click", ".boxes", function(e) {
       e.preventDefault();
    }
    

    You would do that after the winner is found:

    var endGame = function() {
       $(document).on("click", ".boxes", function(e) {
          e.preventDefault();
       }
    }
    
    if ( there is a winner ) {
        endGame();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a very simple JavaScript/jquery code which won't just work correctly. The problem
I have a very simple table called Member , which consists of the following:
I have a very simple JavaScript array that may or may not contain duplicates.
Having coded JavaScript since 1996, I have a very simple issue which I could
As part of learning jQuery, I decided to do a simple tic-tac-toe game in
I have a very simple JavaScript operation which is just not working. I'm using
I have a very simple Javascript (jQuery) code, which just add a class name
I have a very simple html page with the following javascript in it $(function()
I have some very simple javascript code that looks like this: var newWindow =
I'm temporarily stuck with what appears to be a very simple JavaScript problem, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.