gpt4 book ai didi

javascript - 访问表单内的 DIV?

转载 作者:行者123 更新时间:2023-11-28 11:26:02 28 4
gpt4 key购买 nike

我正在尝试使用 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>

最佳答案

document.getElementById("idName")

使用括号

关于javascript - 访问表单内的 DIV?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11095134/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com