无法从文本区域获取文本

编程入门 行业动态 更新时间:2024-10-28 20:23:44
本文介绍了无法从文本区域获取文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我无法从文本区域获取文本:

I cannot get text from my textarea :

非常简单的文本区域:

<textarea id="message" placeholder="Type your text here..."></textarea>

我的飞镖代码:

var area = document.query('#message'); document.query("#send").on.click.add((e) { print('send ${area.text}'); });

当我在区域中写消息并按send时,仅显示:

When i write a message in area and press send , just display :

send

我不不明白为什么我的消息无法打印。 文本不是正确的字段? (innerHtml的相同问题)当我添加

I don't understand why my message is not print. 'text' is not the correct field ? (same problem with innerHtml) When I add

area.text = 'Hello';

该消息在文本区域中可见并且打印良好。

The message is visible in textarea and print is well.

推荐答案

使用 area.value 代替 area.text 。 area.value 是 TextAreaElement 的属性,用于获取显示的实际值,而 area。文本是节点的属性,它获取或设置区域的内容为文本节点。

Use area.value instead of area.text. area.value is a property of TextAreaElement that gets the actual value displayed, whereas area.text is a property of Node that gets or sets the content of area as a text node.

更多推荐

无法从文本区域获取文本

本文发布于:2023-11-10 00:25:19,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1573846.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文本   区域

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!