我试图在input_1文本框的值发生更改时触发函数。getElementById onchange结果对象不是函数
即getElementById('input_1')。onchange导致对象不是函数。
HTML
<form method="GET" id="game_form"></form>
<table border="1" style="background-color:#FFFFCC;border-collapse:collapse;border:1px solid #FFCC00;color:#000000;width:100" cellpadding="3" cellspacing="3">
<tr>
<td id="cell_1"><input type="text" id="input_1" form="game_form" value="x"></td>
<td id="cell_2"><input type="text" id="input_2" form="game_form"></td>
<td id="cell_3"><input type="text" id="input_3" form="game_form"></td>
</tr>
<tr>
<td id="cell_4"><input type="text" id="input_4" form="game_form"></td>
<td id="cell_5"><input type="text" id="input_5" form="game_form"></td>
<td id="cell_6"><input type="text" id="input_6" form="game_form"></td>
</tr>
<tr>
<td id="cell_7"><input type="text" id="input_7" form="game_form"></td>
<td id="cell_8"><input type="text" id="input_8" form="game_form"></td>
<td id="cell_9"><input type="text" id="input_9" form="game_form"></td>
</tr>
</table>
的Javascript
$(window).load(
function checkInput() {
// alert("I am an alert box!1");
var cell = document.getElementById('input_1');
alert(cell.value);
**document.getElementById('input_1').onchange**(
doSomething()
);
}
);
function doSomething(){
alert("I am an alert box!2");
}
为什么不''这里'这将是目标输入。 – 2014-10-20 08:21:37