我正在尝试使用 id "codeDef" 访问 DIV
document.getElementById['codeDef']
但它返回“未定义”。我在这里做错了什么?
这是 HTML 片段:
<div class="section">
<div class="box">
<form method="post" name="exam-company-input-form" action="./">
<table>
<tbody><tr>
<td style="width:150px;padding-left:20px">
Exam Code
</td>
<td style="width:150px;padding-left:20px"><input type="text" maxlength="10" style="width:100%" value="" name="code" onkeyup="javascript:checkExamCode();"></td><td><div id="codeDef">code def</div></td>
</tr>
<tr>
<td style="width:150px;padding-left:20px">
Orca Code
</td>
<td style="width:150px;padding-left:20px"><input type="text" maxlength="10" style="width:100%" value="" name="srycd" onkeyup="javascript:checkOrcaCode();"></td><td id="orcaDef">orca def</td>
</tr>
<tr>
<td style="text-align:center" colspan="3">
<button style="opacity: 1; margin-right: 15px;" onclick="javascript:ResetForm('exam-company-input-form');" class="blue" type="button"><span>リセット</span>
</button><button style="opacity: 1;" onclick="javascript:SubmitForm('exam-company-input-form');" class="blue" type="button"><span>登&#12288;録</span>
</button></td></tr>
</tbody></table>
<input type="hidden" value="master_exam-company-input-do" name="pid">
</form>
</div>
</div>