Solution 1 :

You can create a ID for that row


<td id = "uniqueCell"> ... </td>

Then in your javascript you can do the following.

var uniqueCell = document.getElementById('uniqueCell');

then use that variable to do what you need to do

Problem :

I have 14 generated cells.

How can I select a specific cell from the 14 cells and control it? I want only one cell to be unique, the rest to be how they are displayed in the code, normally.

var isCol = 0;
var board = [];
for (r = 0; r < 7; r++) {
  var line = [];
  for (c = 0; c < 7; c++) {

function prs(c, r) {
  showTable(c, r);
  isCol = (isCol + 1) % 2;

function toColor(col, row, chosen_col, chosen_row) {
  var ret = false;
  switch (isCol) {
    case 0:
      if (row == chosen_row) {
        ret = true;
    case 1:
      if (col == chosen_col) {
        ret = true;

  return ret;

function showTable(chosen_col, chosen_row) {
  var str = "";
  str += "<table border=1>";
  for (row = 0; row < 7; row++) {
    str += "<tr>";
    for (col = 0; col < 7; col++) {
      str += "<td onclick='prs(" + col + "," + row + ")'";
      if (toColor(col, row, chosen_col, chosen_row)) {
        str += " class='grn' ";
      str += ">";
      str += RandomGenerator(50, 500);
      str += "</td>";
    str += "</tr>";
  str += "</table>";

  document.getElementById("ff").innerHTML = str;

function RandomGenerator(min, max) {
  return Math.floor(Math.random() * (max - min) + min);

td {
  border: 2px solid black;
  width: 10px;
  height: 10px;

td:hover {
  background-color: lightgreen;

.grn {
  background-color: green;
  color: white;
<div id='ff'></div>


Comment posted by Calvin Nunes

add an

Comment posted by querySelector()

If it’s a predetermined cell, meaning you know which one it is before the user visits the page, then it would be best to use an ID or a class. If the selected cell is dependent on other factors on the other hand, you might want to look into JavaScript’s

Comment posted by How to Ask

Welcome to SO! Don’t worry about writing the perfect question, we just ask that you do your best, and we’ll try to massage it into something that accomplishes your purpose. As “

Comment posted by the Tin Man

The use of specific IDs, one for each cell, makes sense. You can easily select a cell that way, or randomly do it if that’s your goal.

Comment posted by mikoto dread

Oh I see, that occurred to me but i thought it wouldn’t work for some stupid reasons, currently I’m trying to get the output to give me ID for each Cell currently, i’m not getting any errors but when i click on the website, i get white screen, any tips would be appreciated

Comment posted by willzz100

Sorry for the delay! Are you referring to the id number in your table that corresponds to that cell?

Comment posted by

Comment posted by

See here