在 html 文本框中設置鍵盤插入符號位置 - Set keyboard caret position in html textbox

問題:

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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章