我无法从文本区域获取文本:
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.
更多推荐
无法从文本区域获取文本
发布评论