我正在尝试使用jQuery来替换文本框中文本末尾的光标,这是在用户按“Enter”键后完成的。
我已经实现了“Enter”部分 - 但是我不知道如何在“Enter”之后将光标返回到文本框内输入文本的末尾?
也就是说,目前当用户按下Enter键时,光标会跳到新行,我希望它基本上跳到当前文本的末尾?
一些代码:
jQuery('#textbox').keyup(function (e) {
if (e.keyCode == 13) {
... submits textbox
}
jQuery(this).focus(function() {
var val = this.input.value; //store the value of the element
this.input.value = ''; //clear the value of the element
this.input.value = val; //set that value back.
)};
});