I got this problem since 3 days, so the problem is when I move a piece it will refresh the board so that the ai may move, after the refresh in the board the click function stop working.
function drawBoard(board) {
var str = '';
for( var x = 0 ; x < 8 ; x++ ){
for( var y = 0 ; y < 9 ; y++ ){
str += '<div id="mydiv" class="cell" data-square="'+ x +","+ y +'">' +
'<div class="'+checkPiece(board[x][y]) +' '+ getPieceName(board[x][y]) + '" data-value="' + board[x][y] + '"></div>' +
'</div>';
}
}
$('#board').html(str);
}
After I call again the drawBoard(board); to redraw the board the click function stop working.