reset不是JavaScript中的函数 [英] reset is not a function in JavaScript

查看:63
本文介绍了reset不是JavaScript中的函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的代码我正在尝试:
标记:

Here is my code what i was trying: Markup:

<textarea class="form-control textareaInput" rows="12" id="textareaInput"></textarea>


<div class="row">
     <div class="col-lg-2 text-center">
        <div class="form-group">
             <button  class="form-control btn btn-primary reset" onclick="myFunction()">Reset</button>
         </div>
     </div>
</div>

我的功能:

function myFunction() {
  //alert("ok");
  document.getElementById("textareaInput").reset();
}

当我点击 reset <时出现错误/ code>按钮。

错误:


未捕获TypeError:文档.getElementById(...)。reset不是
函数

Uncaught TypeError: document.getElementById(...).reset is not a function

问题出在哪里?提前致谢。
注意:我没有使用表格标签。

Where is the problem? Thanks in advanced. N.B: i was not using form tag.

推荐答案

你应该使用

document.getElementById("textareaInput").value = "";

这篇关于reset不是JavaScript中的函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆