有人看到我的重置功能有问题吗?

Anyone see a mistake with my Reset function?

好吧,我做了一个功能,可以通过单击按钮清除两个文本框。出于某种原因,我不知道它不起作用。代码粘贴在下面 -

 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() 调用该函数。

在 font-tag 处有一个错误:颜色属性需要引号。

 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>

    <!-- -->