HTML选择标记自动完成 [英] HTML select tag autocomplete
问题描述
< select id =fruits>
< option value =1> Apple< / option>
< option value =2>香蕉< / option>
< option value =3>橙色< /选项>
< option value =4>葡萄< / option>
< option value =5> Ginger< / option>
< / select>
我想要做的是,只要用户关注,选择
,然后他在键盘上点击 G
键,选项 Grapes
将被自动选中,当他再次按下 G
时,将会选择 Ginger
等等上。
我不知道该怎么做。
< a href =http://jsfiddle.net/cse_tushar/gU4a5/ =nofollow> DEMO
你所要求的是下拉列表的默认功能。
如果你想搜索下拉列表,你可以试试这个插件。 p>
$('#fruits')。searchable() ;
您也可以尝试 DEMO
I got some select tag as follows:
<select id="fruits">
<option value="1">Apple</option>
<option value="2">Banana</option>
<option value="3">Orange</option>
<option value="4">Grapes</option>
<option value="5">Ginger</option>
</select>
What I want to do is, whenever the user focus on the select
, and he's clicking on the key "G
" in his keyboard, the option "Grapes
" will be automatically selected, and when he presses "G
" once again, "Ginger
" will be selected and so on.
I have no clue how to do it.
What you are asking for is the default functionality of drop-down-list.
if you want to search the drop-down-list you can try this plugin.
jQuery Searchable DropDown Plugin Demo
$('#fruits').searchable();
you can also try DEMO
这篇关于HTML选择标记自动完成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!