How do I insert a character at the caret with javascript?

前端 未结 6 983
-上瘾入骨i
-上瘾入骨i 2021-01-02 05:55

I want to insert some special characters at the caret inside textboxes using javascript on a button. How can this be done?

The script needs to find the active textbo

6条回答
  •  北海茫月
    2021-01-02 06:24

    Note that if the user pushes a button, focus on the textbox will be lost and there will be no caret position!

提交回复
热议问题