好吧,我已经完成了一个功能,只需单击一个按钮即可清除两个文本框。由于某种原因,我不知道它不起作用。代码粘贴在下面-
function clear() {
document.getElementById("IMEI").value = "";
document.getElementById("Command").value = "";
}
<!-- IMEI -->
<label><font color=#829DBA face="Tahoma"><b>IMEI:</b></font></label>
<input type="text" name="ID" id="IMEI" maxlength="15">
<!-- -->
<!-- AT Command -->
<label><font color=#829DBA face="Tahoma"><b>AT Command:</b></font></label>
<input id="Command" type="text">
<!-- -->
<!-- Clear Button -->
<button type="button" onclick="clear();">Clear</button>
<!-- -->
谢谢
这是clear
一词的范围界定问题,将函数名称更改为cleared
,您将看到它正常工作。如果由于某种原因而无法重命名此功能,也可以使用window.clear()
调用该功能。
在字体标签处是一个错误:颜色属性需要加引号。
function clear() {
document.getElementById("IMEI").value = "";
document.getElementById("Command").value = "";
}
<!-- IMEI -->
<label><font color="#829DBA" face="Tahoma"><b>IMEI:</b></font></label>
<input type="text" name="ID" id="IMEI" maxlength="15">
<!-- -->
<!-- AT Command -->
<label><font color="#829DBA" face="Tahoma"><b>AT Command:</b></font></label>
<input id="Command" type="text">
<!-- -->
<!-- Clear Button -->
<button type="button" onclick="clear();">Clear</button>
<!-- -->