0

I have a function that takes an x and y value, and, using a tables rows and columns, finds the given cell. JQuery:

function changeNum(x,y,num)
{
    var thisRow = $(".sudoku:nth-child("+y+")");
    var thisCell = $(thisRow+":nth-child("+x+")");
}

Something in the thisCell declaration is causing the javascript to stop.

2 Answers 2

3

thisRow is a jQuery set, not a string. Use this :

var thisCell = $(":nth-child("+x+")", thisRow);

You might also directly use

var thisCell = $(".sudoku:nth-child("+y+") :nth-child("+x+")");

Note that if sudoku is the class of the table and not the class of the row, then you'd need a space between .sudoku and :nth-child.

Sign up to request clarification or add additional context in comments.

Comments

0

try lead with ""+

var thisCell = $(""+thisRow+":nth-child("+x+")");

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.