繁体   English   中英

自动完成:在最后一项上按下向下箭头键后,如何专注于第一项?

[英]Autocomplete: How to focus on first item after pressing arrow down key on last item?

专注于最后一项

使用向下箭头键浏览下拉菜单的每个选项。 当专注于最后一个选项时,并按向下箭头键,光标将移至文本框,而不是第一个选项。 如何使光标转到第一个选项?

专注于第一项

您可以使用下面的代码块来解决该问题。

.autocomplete('instance')._move = function( direction, event ) {
    if ( !this.menu.element.is( ":visible" ) ) {
        this.search( null, event );
        return;
    }
    if ( this.menu.isFirstItem() && /^previous/.test( direction ) ||
         this.menu.isLastItem() && /^next/.test( direction ) ) {
        if ( !this.isMultiLine ) {
            this._value( this.term );
        }
        this.menu[ direction ]( event );
        // this.menu.blur();
        return;
    }
    this.menu[ direction ]( event );
}

暂无
暂无

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

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