HTML选择标记自动完成 [英] HTML select tag autocomplete

查看:137
本文介绍了HTML选择标记自动完成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 < 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>

jQuery可搜索的DropDown插件演示



DEMO - 带您的代码

  $('#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.

解决方案

DEMO

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

DEMO - with your code

$('#fruits').searchable();

you can also try DEMO

这篇关于HTML选择标记自动完成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆