2013-07-23 39 views
0

我使用JQuery Ui自动完成并将建议框放置在输入字段上方,如下图所示。当我使用autoFocus:true我可以把重点放在列表的第一个元素上。如何将最后一个元素聚焦到JQuery UI自动完成

现在,我想列表的最后一个元素是焦点(即最接近输入字段的元素)。我怎样才能做到这一点?我怎样才能选择列表中的最后一个元素?

enter image description here

的Javascript:

$input.autocomplete({ 
    source: someUrl, 
    minLength: 2, 
    autoFocus: true, 
    position: { my : "left bottom", at: "left top", collision: "none" } 
}); // end autocomplete 
+1

提供的jsfiddle。你不想扭转项目顺序吗? –

+0

我更新了我的问题。我希望选择最接近输入字段的元素。 – confile

回答

0
$input.autocomplete(someUrl, { 
     matchContains: true, minChars: 1, scroll:true, autoFill: false, scrollHeight: 240, 
     formatItem: function (row, i, max, term) { 
      return row.display; 
     }, 
     formatResult: function (row) { 
      return row.value; 
     }, 
     displayPosition: "left" 
    }); 
+0

你确定这个答案适用于jquery ui自动完成吗? – confile

+0

是的。在这里使用jQuery自动完成使用。 –

+0

这不行! – confile