jQuery Set Cursor Position in Text Area

前端 未结 16 1519
无人共我
无人共我 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:06

    In IE to move cursor on some position this code is enough:

    var range = elt.createTextRange();
    range.move('character', pos);
    range.select();
    

提交回复
热议问题