HTML选择标记自动完成

编程入门 行业动态 更新时间:2024-10-26 19:35:02
本文介绍了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 等等上。

我不知道该怎么做。

解决方案

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选择标记自动完成

本文发布于:2023-11-16 16:03:51,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:自动完成   标记   HTML

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!