Tic Tac Toe Game: Play Online Now - Free HTML Code
<html>
<head>
<title> Tic Tac Toe </title>
</head>
<body>
<h1> Tic Tac Toe </h1>
<table>
<tr>
<td> <input type='button' value='' onclick='clickedButton(this)' /> </td>
<td> <input type='button' value='' onclick='clickedButton(this)' /> </td>
<td> <input type='button' value='' onclick='clickedButton(this)' /> </td>
</tr>
<tr>
<td> <input type='button' value='' onclick='clickedButton(this)' /> </td>
<td> <input type='button' value='' onclick='clickedButton(this)' /> </td>
<td> <input type='button' value='' onclick='clickedButton(this)' /> </td>
</tr>
<tr>
<td> <input type='button' value='' onclick='clickedButton(this)' /> </td>
<td> <input type='button' value='' onclick='clickedButton(this)' /> </td>
<td> <input type='button' value='' onclick='clickedButton(this)' /> </td>
</tr>
</table>
<script>
var playerTurn = 'X';
function clickedButton(button) {
button.value = playerTurn;
if (playerTurn == 'X') {
playerTurn = 'O';
}
else {
playerTurn = 'X';
}
}
</script>
</body>
</html>
原文地址: https://www.cveoy.top/t/topic/lnnl 著作权归作者所有。请勿转载和采集!