搜索文档
insertAtCaret(dom, str?): void
dom
str?
void
将文本插入到文本区域的光标位置
_应用场景:_如在评论框里,在光标位置里插入emoji等
HTMLTextAreaElement
HTMLInputElement
undefined
str
string
''
Example
<textarea name="textarea" rows="10" cols="50">你好世界~</textarea> const editText = document.querySelector('textarea'); insertAtCaret(editText, 'hello world'); // => 在光标位置插入'hello world'