可能重复:
jQuery 在文本区域中设置光标位置
当带有文本的输入被聚焦时,光标从右侧文本的末尾开始。如何使光标位于焦点的左侧?
我见过使用“setCursor”的示例,但我收到一个错误,即 setCursor 未定义。
<input type="text" class="myInput">
Tabbing into this should put my cursor at the left!
</input>
setCursor 抛出一个未定义的错误。
$(".myInput").focus(function(){
var node = $(this);
setCursor(node, 0);
});