javascript - 如何重置文本区域?
问题描述
在我使用它之后,我无法第二次在文本区域中显示表情符号,无论是通过使用键盘书写还是之前插入了一个表情符号。我不知道为什么自从第一次在 textarea 中显示表情符号后它就没有了。
let template = document.querySelector('#chat')
let div = document.importNode(template.content.firstElementChild, true)
let textarea = chatDiv.querySelector('.messageArea')
let btnShowEmojis = document.createElement('button')
btnShowEmojis.addEventListener('click', () => {
// Test
textarea.innerText = String.fromCodePoint(0x1f600)
// Also tried with textContent like
// textarea.textContent = String.fromCodePoint(0x1f600)
})
// Empty the text content
textarea.innerText = ''
// Or
// textarea.textContent = ''
解决方案
推荐阅读
- javascript - 如何在每个 if else 块中优化 if else
- php - 如何在弹性搜索中为整数值编写匹配字符串且不等于 0 的查询
- c++ - C++没有匹配函数调用'strlcpy'
- scrapy - 消除几个同名蜘蛛的 Scrapy 警告
- javascript - 使用 mongoose 查询 mongoDB 中的子文档
- webdriver-io - JUnit 报告器生成空的 xml 文件
- html - 如果句子进入下一行,如何将jquery自动完成定位在单词旁边?
- python - Python3.7 获取两个目录下多个文件的差异
- react-native - 系统重启后 Expo 不启动
- r - 如何使用“for”循环用 ggplot2 绘制点?