2

たとえば、jquery オートコンプリート UI ウィジェットを使用しています。

var names = ["John", "Jack", "Nick", "Tom", "Joyce", "Nancy"];
$("#nameInput").autocomplete({
    source: names
});

Gmail の「To」テキスト ボックスのように動作するようにしたいと思います。

具体的には、入力時に最も一致するものを強調表示して、Enter キーを押すと、強調表示された値が選択されるようにしたいと思います。

つまり、上下の矢印やマウスを使用して選択する必要はありません。

ご提案ありがとうございます。

4

1 に答える 1

1

オートコンプリート フィルターは入力中に結果が表示されるため、最初の結果を自動的に強調表示するだけで済みます。

//PSEUDO CODE
$('input').autocomplete({
  source: //your code to link to the source,
  open: //your code to select the first element, I cannot see there is a built-in method to select the first option, but you could firebug the menu and use css class to target the correct element.
});
于 2010-12-05T21:46:59.010 に答える