繁体   English   中英

使用jQuery屏蔽输入将光标移动到结束输入

[英]Move cursor to end input with jquery masked input

我使用的是jQuery masked输入插件,当我获得该字段的焦点并将焦点(模糊,焦点)返回到开头时,需要始终将光标留在结尾处,但我不能。

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

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

},

您可以将selectionStart和selectionEnd设置为值长度。 例如

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM