以编程方式使 input[type=url] 的数据列表与 JavaScript 一起出现 [英] Programmatically make datalist of input[type=url] appear with JavaScript

查看:13
本文介绍了以编程方式使 input[type=url] 的数据列表与 JavaScript 一起出现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Chrome 中,目前只有在输入或双击 input 元素时才会出现数据列表,例如http://jsfiddle.net/r7Y4v/

In Chrome and as for now the Datalist only appears when typing or double clicking on the input element, e.g. http://jsfiddle.net/r7Y4v/

我正在努力使数据列表更快出现.理想情况下,我会在输入旁边放一个小下拉箭头",点击后会显示数据列表.

I'm trying to make the datalist appear sooner. Ideally I would put a little "dropdown arrow" next to the input that when clicked would make the Datalist appear.

我正在寻找 webkit 解决方案.

I'm looking for a webkit solution.

推荐答案

我在规范中找不到任何关于如何执行此操作的内容.

I can't find anything in the specification how to do this.

我还注意到当前浏览器中的实现似乎有很大差异(单击与 dbl-click、箭头键、完整列表与过滤列表以及过滤器如何匹配部分输入等).

Also I noticed that the implementation in current browsers seem to vary quite a bit (click vs dbl-click, arrow-key's, full versus filtered list and how filters match the partial input, etc).

对我来说,目前似乎仍然没有正常工作的组合框,数据列表似乎还处于起步阶段.

To me, it seems that for now there is still no properly working combo-box and the data-list seems to be in it's infancy.

因此,您目前最好推出自己的库或使用现成的库.
在我看来,'minimul datalist' 库相当流行(阅读的好链接).
在该页面上有一个链接,它是 GitHub 代码 和一个 演示页面.

So it appears you'd currently be better of to roll your own or use a ready library.
It seems to me the 'minimul datalist' library is rather popular (good link to read to).
On that page is a link to it's GitHub code and a demo page.

旁注: 我希望有人能给出更好的答案!此外,起初我认为省略箭头是个好主意-button 以便人们可以为下拉按钮提供更好的样式选项,如果他们想要一个可以连接到数据列表/自动完成/组合框的按钮.我很惊讶所有这些似乎仍然未指定并且不受本机支持.规范编写者,请给我们简单的原生组合框(过期太久了),然后添加过滤器之类的香料!

Side-note: I'd love that some-one gives a better answer! Also, at first I thought it was a good idea to leave out the arrow-button so people could have better styling-options for a drop-down button if they wanted one that they could hook-up to the datalist/autocomplete/combobox. I'm surprised all this still seems unspecified and not natively supported. Please, spec-writers, give us the simple native combo-box (that is overdue for so long) and then add spice like filters!

自 2012 年 8 月以来,Chromium 项目有一个开放的功能请求,要求提供下拉功能:

There is an open Feature request since August 2012 on the Chromium project that asks for a drop-down functionality:

这篇关于以编程方式使 input[type=url] 的数据列表与 JavaScript 一起出现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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