【问题标题】:Move cursor to end input with jquery masked input使用 jquery 屏蔽输入将光标移动到结束输入
【发布时间】:2014-04-11 18:21:09
【问题描述】:

我正在使用 jQuery 蒙版输入插件,当我获取字段的焦点并将焦点(模糊、焦点)返回到开头时,需要始终将光标留在末尾但我不能.

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

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

},

【问题讨论】:

标签: javascript jquery input maskedinput


【解决方案1】:

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-11-08
    • 2017-02-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多