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

  • Home
  • SEARCH
  • 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 8823153
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:17:00+00:00 2026-06-14T06:17:00+00:00

I am attempting to create a tic-tac-toe browser game utilizing JavaScript and jQuery, along

  • 0

I am attempting to create a tic-tac-toe browser game utilizing JavaScript and jQuery, along possibly with PHP.

I have the board arranged how I like utilizing a table and adding borders appropriately. Each cell in the tic-tac-toe board has its own unique id, e.g topleft, topright, botleft, etc.

For testing purposes, before I can even get to writing the code supporting the game, I am attempting to get an "X" to appear when the user clicks an appropriate spot, however I am having no luck.

Here is the JavaScript I have so far:

 <script type="text/javascript">

                function mark()
                {
                        document.getElementById('topleft').innerHTML = "X";
                }

                function init()
                {
                        var button = document.getElementById('topleft');
                        button.addEventListener('click', mark, false);
                }

                $(document).ready(function()
                {
                        $('#topleft').click(function()
                        {
                        });

                });
        </script>

And here is the html:

<body>
        <div>
                <table>
                        <tr>
                                <td id="upleft">
                                </td>
                                <td id="upcenter">
                                </td>
                                <td id="upright">
                                </td>
                        </tr>
                        <tr>

By my logic, the page loads, and then topleft gets a click listener. Upon clicking that cell the listener is tripped, which then calls the function mark to place an X in the cell, however nothing appears clickable on the page, and no mark appears afterwards.

If anyone can spot an error or has a suggestion I’d be grateful!

Additionally, if you have any ideas for programming the logic behind a tic-tac-toe board (nothing too fancy) I’d be grateful as well.

  • 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-14T06:17:01+00:00Added an answer on June 14, 2026 at 6:17 am

    try it this way:

    $('#topleft').click(function() {
        $(this).text('X');
    });
    

    Next step, don’t use #topleft directly, but generic case className ($('.tictactoe-case')) to not repeat yourself.

    Good luck!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am attempting to create a report, utilizing a matrix, that only displays columns
I'm attempting to create a CustomControl which will have various properties affected by an
I'm attempting to create a linked list of length n using Python. I have
I am attempting to create a flipbook using jQuery Booklet plugin. I am following
I'm currently attempting to create a browser-based Calendar which allows jobs or meetings, etc.
I am attempting to create a custom tableview where I have a list of
While attempting to create a replacement tablespace for USER, I accidentally created a datafile
Im attempting to create a new operator :? on lists, which operates the same
I attempting to create an 800x500 div with four overlapping divs inside the container
I attempting to create custom tabs using this . But when I try to

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.