I want to check if innerHtml have X or O , so i can not add again any thing else , but it\'s not working . it stop after adding the check code , I\'m trying here to do a simple
Your code is very hard to read. I've whipped a quick almost working script for you to read and understand http://jsfiddle.net/mendesjuan/MQ9Nr/
However, it seems that for what you need, you just have to check if the text is empty or not. Here are a few suggestions
JS
$(function(){
var turn = 0;
var xos = ["x", "o"];
$("td").click(function(){
var $this = $(this);
if ($this.text()) {
return;
} else {
$this.text(xos[turn]);
turn = (turn + 1) % 2;
}
});
});
HTML
X ,O Game