-1
這是我的code.Id正在通過。但不能改變value.Its顯示null的空值更改值。我需要將其值更改爲「X」onclick。如何更改點擊按鈕的值?
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="tictactoe.css" />
</head>
<body>
<table cellpadding="0" cellspacing="0">
<tr>
<td><input type="button" value=" " class="buttons" id="1" onclick="tictactoe(this.id)"></td>
<td><input type="button" value=" " class="buttons" id="2" onclick="tictactoe(this.id)"></td>
<td><input type="button" value=" " class="buttons" id="3" onclick="tictactoe(this.id)"></td>
</tr>
<tr>
<td><input type="button" value=" " class="buttons" id="4" onclick="tictactoe(this.id)"></td>
<td><input type="button" value=" " class="buttons" id="5" onclick="tictactoe(this.id)"></td>
<td><input type="button" value=" " class="buttons" id="6" onclick="tictactoe(this.id)"></td>
</tr>
<tr>
<td><input type="button" value=" " class="buttons" id="7" onclick="tictactoe(this.id)"></td>
<td><input type="button" value=" " class="buttons" id="8" onclick="tictactoe(this.id)"></td>
<td><input type="button" value=" " class="buttons" id="9" onclick="tictactoe(this.id)"></td>
</tr>
</table>
</body>
<script type="text/javascript">
tictactoe = function(id) {
var box = document.getElementById("this.id");
box.value = "X";
}
</script>
</html>
var box = document.getElementById(passedArgument);'爲什麼引用...它將被視爲字符串... – Rayon