如何在 HTML 中创建可编辑的下拉列表? [英] How can I create an editable dropdownlist in HTML?

查看:30
本文介绍了如何在 HTML 中创建可编辑的下拉列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个带有下拉列表的文本字段,让用户可以选择一些预定义的值.用户还应该能够输入一个新值或从下拉列表中选择一个预定义的值.我知道我可以为此使用两个小部件,但在我的应用中,如果将其统一在一个小部件中会更加符合人体工学.

I'd like to create a text field with a dropdown list that lets the user choose some predefined values. The user should also be able to type a new value or select a predefined one from a dropdown list. I know that I can use two widgets for that but in my app it would be more ergonomnic if it was unified in a one widget.

是否有标准小部件或我必须使用第三方 javascript?

Is there a standard widget or do I have to use a third party javascript?

浏览器的便携性怎么样?

How about browser portability?

推荐答案

最好的方法可能是使用第三方库.

The best way to do this is probably to use a third party library.

jQuery UI jQuery UIdojo dojo.jQuery 更受欢迎,但 dojo 允许您在 HTML 中声明性地定义小部件,这听起来更像您正在寻找的.

There's an implementation of what you're looking for in jQuery UI jQuery UI and in dojo dojo. jQuery is more popular, but dojo allows you to declaratively define widgets in HTML, which sounds more like what you're looking for.

您使用哪一种取决于您的风格,但两者都是为跨浏览器工作而开发的,而且两者的更新频率都比复制和粘贴代码要高.

Which one you use will depend on your style, but both are developed for cross browser work, and both will be updated more often than copy and paste code.

这篇关于如何在 HTML 中创建可编辑的下拉列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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