18910140161

JavaScript-TextBox文本值未定义或消息堆栈溢出

顺晟科技

2022-10-19 14:22:35

185

我要将输入的名称赋予标题。这是我的textarea和header,它在另一个html文件中:

<textarea class="form-control" placeholder="Leave a comment here" id="floatingTextarea"></textarea>
<h1 id="noteheader"></h1>

我试图通过以下代码获取它的值:

<textarea class="form-control" placeholder="Leave a comment here" id="floatingTextarea"></textarea>
<h1 id="noteheader"></h1>

但它似乎没有定义,即使我在textarea中键入了一些东西。 我已经用innerHTML、innerText和val尝试过了,它只是给出了一个神秘的输出,比如:

<textarea class="form-control" placeholder="Leave a comment here" id="floatingTextarea"></textarea>
<h1 id="noteheader"></h1>

顺晟科技:

您的代码缺少以下内容:

是获取值的JS属性。对于JQuery代码,您有

代码中有太多错误。

这里是纯jQuery版本。

  • TAG:
相关文章
我们已经准备好了,你呢?
2024我们与您携手共赢,为您的企业形象保驾护航