<!DOCTYPE>
<html>
<head>
<title>Крестики-нолики</title>
<meta charset="utf-8">
</head>
<body>
<form>
<table height="" width="" border="0">
<tr>
<td> <input type="button" name="b1"> </td>
<td> <input type="button" name="b2"> </td>
<td> <input type="button" name="b3"> </td>
</tr>
<tr>
<td><input type="button" name="b4"></td>
<td><input type="button" name="b5"></td>
<td><input type="button" name="b6"></td>
</tr>
<tr>
<td><input type="button" name="b7"></td>
<td><input type="button" name="b8"></td>
<td><input type="button" name="b9"></td>
</tr>
</table>
</form>
<script>
let hod = 0,
pol = document.querySelectorAll('input[type="button"]'),
arrX=[],
arrO=[],
win=(a)=>[[0,1,2],[3,4,5],[6,7,8],[0,3,6],[1,4,7],[2,5,8],[0,4,8],[2,4,6]].find(el=>el.every((el)=>a.includes(el)));
pol.forEach((el,n)=> el.onclick = e =>{
el.value = hod++ % 2 ? "0" : "X";
el.value !== ''&& (el.value == 'X'?arrX.push(n):arrO.push(n));
if(win(arrO)) alert('Выиграли: O');
else if(win(arrX)) alert('Выиграли: X');
});
</script>
</body>
</html>