无法从文本区域获取文本 [英] Cannot get text from text area

查看:78
本文介绍了无法从文本区域获取文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.

这篇关于无法从文本区域获取文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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