使用jquery蒙板输入将光标移动到结束输入

时间:2014-04-11 18:21:09

标签: javascript jquery input maskedinput

我使用jQuery蒙面输入插件,当我拍摄场焦点并将焦点(模糊,焦点)返回到开头时,需要始终将光标留在最后但是我不能。

$('#id_origin_zipcode').bind('focus', $.proxy(this.moveCursorToEnd, this));

moveCursorToEnd: function(e){
    var value = $('#id_origin_zipcode').val();
    $('#id_origin_zipcode').val(value);

},

1 个答案:

答案 0 :(得分:2)

您可以将selectionStart和selectionEnd设置为值长度。 e.g。

<input type="text" onFocus="this.selectionStart = this.selectionEnd = this.value.length;" />
相关问题