問題:
Does anybody know how to move the keyboard caret in a textbox to a particular position?有人知道如何將文本框中的鍵盤插入符號移動到特定位置嗎?
For example, if a text-box (eg input element, not text-area) has 50 characters in it and I want to position the caret before character 20, how would I go about it?例如,如果一個文本框(例如輸入元素,而不是文本區域)中有 50 個字符,而我想將插入符號放在字符 20 之前,我將如何處理?
This is in differentiation from this question: jQuery Set Cursor Position in Text Area , which requires jQuery.這與這個問題不同: jQuery Set Cursor Position in Text Area ,這需要 jQuery。
解決方案:
參考一: https://en.stackoom.com/question/29Ka參考二: https://stackoom.com/question/29Ka