Easily done! Using JavaScript to generate a blinking cursor on a table

Working on a project to develop a dynamic version of the classic game Tic-Tac-Toe...

However...

Every table cell is displaying an irritating flashing cursor, almost like it's behaving as an input field.

Any insights into why this is happening...? Or suggestions on how to fix it?

Everything seems fine in Chrome, but Firefox version 26.0 is showing this issue.

Check out the current live version:


FULL CODE:

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Tic Tac Toe! (and more...)</title>
  <meta name="description" content="Tic Tac Toe">
  <meta name="author" content="SinSysOnline">
  <script src="http://code.jquery.com/jquery-latest.min.js"></script>
  <style>
  body{
    font-family:"Lucida Console", Monaco, monospace;
  }
  td{
    padding:0;
    margin:0;
    border-right:1px solid #000;
    border-bottom:1px solid #000;
    width:100px;
    height:100px;
    text-align:center;
    font-size:72px;
  }
  td:last-child{
    border-right:none;
    border-bottom:1px solid #000;
  }
  tr:last-child td{
    border-bottom:none;
  }
  table{
    padding:25px;
    margin:0 auto;
    cursor:pointer;
  }
  #dashboard{
    background:#CCC;
    padding:15px;
    border:1px solid #000;
    box-shadow:0 5px 15px #000;
  }
#alert{
    font-family: "Courier New", Courier, "Lucida Sans Typewriter", "Lucida Typewriter", monospace;
    color:#F00;
    text-align:right;
}
.check{
    background:url("check.png");
}
</style>
</head>

<body>
<div id="dashboard">
    <p>How large is your grid? (3-10)</p>
    <input type="text" id="size" size="1" />
    <input type="button" id="go" value="Create Board / Reset" />
    <p id="alert">Alerts Live Here</p>
</div>

<table id="board">
</table>

<script>
var b=[], c=0;
$("#go").click(function () {
    var b=[],
        s = parseInt($("#size").val());

    if (s<3 || s>10) { alert("That is not a valid input. Please select 3-10"); return; }

    $('#board tr').remove();
    $('#alert').text("Your Turn!");

    for(var i=0;i<s;i++){
        var tempArr = [];
        for(var j=0;j<s;j++){ tempArr[j] = ""; }
        b.push(tempArr);
    }

    for (var i = 0; i < s; i++) {
        var $tr = $('<tr />', {id: 'row_' + i }).data('index', i + 1);
        $("#board").append("<tr id='row_" + i + "'>");

        for (var j = 0; j < s; j++) {
            $('<td />', {
                id: 'col_' + j
            }).data('index', j + 1).appendTo($tr);
        }

        $("#board").append($tr);
    }

    $("#board").on('click', 'td', function () {
        var $td = $(this),
            td = $td.data('index'),
            row = $td.parent().data('index');

        if(b[row-1][td-1]!==""){
            alert("Somebody already went there...");
        } else {
            b[row-1][td-1] = "X";
            $td.addClass("check");
            $('#alert').text(b);
        }
    });
});
</script>
</body>
</html>

Answer №1

Simple CSS Tricks

Take a look at this helpful website

table{

    cursor:pointer;
    padding:10px;
    margin:5px;
    border:1px solid #333;
    width:200px;
    height:150px;
    text-align:center;
    font-size:18px;
  }

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Error message displayed: "Unexpected token 'H' when attempting to render Markdown

I've been working with the react markdown library and wanted to share my code: import Markdown from 'react-markdown'; import PreClass from './PreClass'; type MarkdownFormatTextProps = { markdown: string; tagName?: string; ...

Problem encountered when trying to show the Jquery Ajax response on an HTML page

I'm facing a challenge with loading a page that needs to display values with dynamic pagination. To retrieve these values, I am making a REST call which returns a JSON object. Although I can see the JSON output in the browser console, I am unable to d ...

The React MUI Tab component triggers a re-render and clears the states of its child components

In our endeavor to create a Tab Page using React MUI, we aim for each Tab to contain a child component. While there are no issues when adding these child components individually to a page without tabs, problems arise when incorporating them within the Tab ...

Having trouble loading the Google API using getScript. Is displaying a ReferenceError message: "Variable google not found."

I am attempting to dynamically load the Google API using the getScript() method for implementing a "Place Autocomplete Address Form". For more information, you can visit this link: https://developers.google.com/maps/documentation/javascript/examples/places ...

What is the approach for for loops to handle non-iterable streams in JavaScript?

In the realm of node programming, we have the ability to generate a read stream for a file by utilizing createReadStream. Following this, we can leverage readline.createInterface to create a new stream that emits data line by line. const fileStream = fs.cr ...

Unable to center text within a CSS div rotated 90 degrees due to width limitations caused by rotation; solution involves utilizing flexbox

Currently, I am working on creating a tab positioned on the right side, as illustrated in the image below: The desired width for the tab on the right is only 25px. To achieve this layout, I am utilizing flexbox for the container that houses the purple par ...

Tips for adding an asterisk to the label of a Material-UI switch component

I am trying to include an asterisk symbol in the label by passing a required prop with a property, but it doesn't seem to be functioning correctly. <FormControlLabel control={ <Switch onChange={event => ...

Guide to Indicating an Icon in Front of an HTML Link and Emphasizing Both with Tap

When using an iOS UIWebview, I am facing the issue of needing to add an icon before standalone links that are within a locally loaded HTML file. In addition to adding the icon, I also need both the icon and link to be highlighted when tapped. The desired ...

AngularJS directive: handling child elements

Is there a way to structure the directive below in order to have access to all the ul elements within the link function? In the code snippet provided, when examining the elm (logged in console), it appears as a comment type and ul are displayed as sibling ...

The Angular Material dialog fails to display content when triggered within an event listener in Google Maps

Within my project, I am utilizing Angular 6.0.6 and Angular Material 6.3.0. One issue I have encountered is with a dialog component that I have added to the entryComponents in the app module. Strangely, when I attempt to open this dialog within the rightcl ...

What is the best way to define coordinates or set margins for the autoTable component in jsPdf when using React js?

While working with the jsPdf library to create a PDF in React, I am encountering an issue where I am unable to set margins for the autoTable when there are multiple tables on a single page. Below is the code snippet: import React from "react"; ...

Error in Jquery click function not being triggered

I'm in the process of developing an eCommerce platform where users can choose options and have their shopping carts automatically updated using jQuery. Users will be presented with a few radio buttons to select from, and as they make their choice, th ...

What is the best way to specify the stream responseType for my client?

Is there a way to download a file from my express js app using AJAX instead of server-side handling? const response = await Axios({ method: 'GET', url: url, responseType: 'stream' }) Instead of piping the data directly to ...

Get rid of the drop-down shadow effect

Currently working on a website project for a client and looking to remove the blue "shadow" effect from the dropdown menus. I believe the code that needs editing is as shown below: .main_nav ul.sub-menu { position: absolute; top: 65px; width: ...

What is the best way for me to determine the average number of likes on a post?

I have a Post model with various fields such as author, content, views, likedBy, tags, and comments. model Post { createdAt DateTime @default(now()) updatedAt DateTime @updatedAt id String @id @default(cuid()) author U ...

Transforming table data into a JSON format

My goal is to generate a specific JSON format from a table. The table consists of rows and 4 columns. You can view my table here. I aim to create a JSONArray based on the table. The first value in the left column serves as the key in the JSON, while the la ...

Align a component vertically in a FlexBox using Material UI

I have a React app where I created a card with specified min width and height, containing only a header. I want to add flexbox that occupies the entire left space with justify-content="center" and align-items="center". This way, when I insert a circular pr ...

Floating color problem

Do you know why the social icons turn black when hovered over? Could it be related to the navbar buttons? Is there a way to change the hover color to blue or red only? Link to code snippet <body> <nav class="navbar navbar-default navbar-fixed-t ...

What causes the gap between a parent div and inner div in react components?

I have a relatively simple React component that I'm working on. Even though I am quite new to React, I have tried various methods to eliminate the white space issue but so far have been unsuccessful in determining what is causing it. Negative margin s ...

Having Trouble Retrieving and Updating Records in MS CRM?

My current situation involves working with Microsoft Dynamics coding for the first time, and I am in need of a solution for my code. I have established two entities called Acc and Con, where Acc serves as the parent entity and Con is the child entity of A ...