0

So, I'm building a little board game in HTML, Javascript, and CSS. I have it working when its just a series of functions, and I've got everything working when its an object, except for this one little, vital thing. Here's the code:

othello_game.prototype.addPlayerTurns = function(cur_obj){
//var grid = document.getElementById("othelloGrid");
//console.log(grid);
var x = 0;
var y = 0;
//console.log($("#othelloGrid td"));
$("#othelloGrid td").each(function(){
    console.log(x, y);
        $(this).click(function(){
            cur_obj.playerTurn(x, y, cur_obj);
        });
        y++;
        if (y == 8){
            y = 0;
            x++;
            if (x == 8){
                x = 0;
            }
        }
});
}

Now, the trouble is that if in the line "cur_obj.playerTurn(x, y, cur_obj);" I can substitute specific numbers, let's say 4 and 2, and sure enough, the 'td' related to my 2-dim array will work. But if I leave the variables in there, I get nothing. No error, no nothing. Any thoughts?

user3042535
  • 11
  • 1
  • 3

0 Answers0