I am new to programming as to stack overflow so be easy on me. i am making an tic tac toe game and haven't found a to mark a random_cell and append and image to it so if you could help it will be of most help. jquery are also welcome
var x_or_o = ["x","o"];
var user = x_or_o[Math.floor(Math.random()*x_or_o.length)];
function random_cell(){
var cells = ["zero","one","two"];
return ("#"+cell[Math.floor(Math.random()*cells.length)]+"_"+cell[Math.floor(Math.random()*cells.length)]);
}
function clink(id_ele){
$(id_ele).one(("click",water(id_ele)));
}
function water(id_ele){
$(id_ele).click(function(){
if (user == "x"){
$(id_ele).append("<img src =img/x.png>").addClass("done-x");
if (! random_cell.hasClass()){
$(random_cell).append("<img src =img/o.png>");
}
else{
random_cell();
water(id_ele);
}
}
else if (user == "o"){
$(id_ele).append("<img src =img/o.png>").addClass("done-o");
}
}
)
}
clink("#zero_zero");
clink("#zero_one");
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Tic Tac Toe</title>
<link rel="stylesheet" href="css/main.css">
</head>
<body>
<header>
<h1>TIC TAC TOE</h1>
</header>
<section>
<table>
<tr>
<td id = "zero_zero"></td>
<td id = "one_zero"></td>
<td id = "two_zero"></td>
</tr>
<tr>
<td id = "zero_one"></td>
<td id = "one_one"></td>
<td id = "one_two"></td>
</tr>
<tr>
<td id = "two_zero"></td>
<td id = "two_one"></td>
<td id = "two_two"></td>
</tr>
</table>
</section>
<footer>
<p>© Kunal Mehta 2016</p>
<img src="img/facebook.png" alt="">
<img src="img/twitter.png" alt="">
</footer>
<script src="js/jquery.js"></script>
<script src="js/main.js"></script>
</body>
</html>