jQuery Set Cursor Position in Text Area

前端 未结 16 1481
无人共我
无人共我 2020-11-21 11:42

How do you set the cursor position in a text field using jQuery? I\'ve got a text field with content, and I want the users cursor to be positioned at a certain offset when

16条回答
  •  无人共我
    2020-11-21 12:25

    Just remember to return false right after the function call if you're using the arrow keys since Chrome fricks the frack up otherwise.

    {
        document.getElementById('moveto3').setSelectionRange(3,3);
        return false;
    }
    

提交回复
热议问题