[英]HTML5 datalist tag is not working as expected in Safari
I have a datalist tag which allows my users to have a suggestion box.我有一个 datalist 标签,它允许我的用户有一个建议框。 Now i know that this feature is not supported in safari.
现在我知道 safari 不支持此功能。 So what can i do to solve this issue?
那么我能做些什么来解决这个问题呢?
Here is my code - I'm actually populating my values with database dynamically..这是我的代码 - 我实际上是用数据库动态填充我的值..
<select id="select_departure_city"style="border-radius:6px" onchange="this.nextElementSibling.value = $('#select_departure_city option:selected').text().trim()"></select>
<input id="input_departure_city" class="form-control admin-input width-80 height-34p padding-0" name="departure_city" type="text" list="listDepartureCity" />
<datalist id="listDepartureCity" ></datalist>
Before posting this i tired many solutions but none of them is worked for me.在发布此之前,我厌倦了许多解决方案,但没有一个对我有用。 I tired
我累了
As in these posts, Select tag with in datalist tag is solution like this.在这些帖子中,选择带有 in datalist 标签的标签是这样的解决方案。
<datalist id="languages">
<select>
<option value="JavaScript">JavaScript</option>
<option value="Haskell">Haskell</option>
</select></datalist>
But in my case Options tag are not place within select tag after populating dynamically.但在我的情况下,动态填充后, Options标签未放置在select标签中。 My code after adding select is as below
添加选择后我的代码如下
<datalist id="listDepartureCity">
<select></select>
<option value="JavaScript">JavaScript</option>
<option value="Haskell">Haskell</option>
</datalist>
How can I solve this?我该如何解决这个问题?
If you need to use a feature that's not widely supported by all browsers, chances are you'll need a polyfill.如果您需要使用并非所有浏览器都广泛支持的功能,您很可能需要一个 polyfill。 Here's one for datalist that might work for you: https://github.com/thgreasi/datalist-polyfill
这是一个可能适合您的数据列表: https : //github.com/thgreasi/datalist-polyfill
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.