i a making a tic-tac-toe game and i now want to know how i can make a button unclickable after a click. here is the game field:
<div id="gamefield">
<table border="0">
<tr>
<td><img alt="" title="" src="img/empty.jpg" /></td>
<td><img alt="" title="" src="img/empty.jpg" /></td>
<td><img alt="" title="" src="img/empty.jpg" /></td>
</tr>
<tr>
<td><img alt="" title="" src="img/empty.jpg" /></td>
<td><img alt="" title="" src="img/empty.jpg" /></td>
<td><img alt="" title="" src="img/empty.jpg" /></td>
</tr>
<tr>
<td><img alt="" title="" src="img/empty.jpg" /></td>
<td><img alt="" title="" src="img/empty.jpg" /></td>
<td><img alt="" title="" src="img/empty.jpg" /></td>
</tr>
</table>
</div>
this is the randomstart function:
var randomStart = Math.floor(Math.random() * 2);
this is the function for the gamefield:
$("#gamefieldtr td").click(function() {
if ($(".game-button").html() == "Start spel") {
alert("you can't start");
} else {
if(randomStart == 0){
var val = $(this).children().attr('src', 'img/cross.jpg');
randomStart = 1;
$("#playerTurn").html("1");
$("#turnImg").attr("src", "img/circle.jpg");
}
else {
var val = $(this).children().attr('src', 'img/circle.jpg');
randomStart = 0;
$("#playerTurn").html("0");
$("#turnImg").attr("src", "img/cross.jpg");
$('src', 'img/circle.jpg').unbind("click");
}
}
});