首页 > 解决方案 > 如何重置文本区域?

问题描述

在我使用它之后,我无法第二次在文本区域中显示表情符号,无论是通过使用键盘书写还是之前插入了一个表情符号。我不知道为什么自从第一次在 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 = ''

标签: javascripttextareaemoji

解决方案


推荐阅读