html datalist元素auto建议行为 [英] html datalist element auto suggest behavior
问题描述
我注意到,当你将一个文本字段连接到一个datalist时,不同的浏览器有不同的行为。有些浏览器会以开头输入您输入的内容(IE,chrome)显示条目,而其他浏览器则会显示包含您输入的子字符串的条目(firefox)。
I noticed that different browsers have different behavior regarding to suggesting values for a text field when you hook it up to a datalist. Some browsers show the entries which exactly starts with what you've typed(IE, chrome), while others show entries which contain what you've typed as a sub-string(firefox).
例如,在文本框中键入 i
,并观察建议:
For example, type i
into the text box, and observe the suggestions:
browser:
<datalist id="browsers">
<option value="Google Chrome">Google Chrome</option>
<option value="Internet Explorer">Internet Explorer</option>
<option value="Firefox">Firefox</option>
<option value="Opera">Opera</option>
<option value="Safari">Safari</option>
<option value="Others">Others?</option>
</datalist>
<input type="text" name="browser" list="browsers">
(或者这里是一个小提琴,如果你喜欢 http://jsfiddle.net/yaj8ut3m/)
(or here's a fiddle, if you prefer http://jsfiddle.net/yaj8ut3m/ )
在chrome和IE中,它只会建议 Internet Explorer
,但firefox会建议 Internet Explorer
, Firefox
和 Safari
。
In chrome and IE, it will suggest only Internet Explorer
, but firefox will suggest Internet Explorer
, Firefox
, and Safari
.
是否有某种方法可以指定要使用哪种自动建议过滤行为?
't acceptable
note: javascript solutions aren't acceptable
推荐答案
如果问题是:
有一些方法可以指定要使用哪些自动建议过滤行为?
"Is there some way to specify which auto suggest filtering behavior to use?
注意:javascript解决方案不可接受
note: javascript solutions aren't acceptable"
答案将(悲伤地)是:没有没有,这取决于浏览器的实现和datalist标签没有任何属性。
the answer will (sadly) be: No there isn't, this depend on browser's implementation and the datalist tag hasn't any attribute.
我不得不说这是充分的插件,并相对简单地写一个,但使用js。
I have to say that is full of "plugins" and is relatively simply to write one but using js.
这篇关于html datalist元素auto建议行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!