数据列表在Safari中不起作用 [英] Datalist not working in Safari

查看:139
本文介绍了数据列表在Safari中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用数据列表制作了一个简单的自动建议框.它在Safari中不起作用.有没有解决的办法.

I made a simple auto suggest box using data list. It does not work in Safari. Is there any work around to it.

<input list="places" placeholder="Enter origin airport" />
<datalist id="places">
    <option value="Manchester Ringway Interantional">
    <option value="Chicago O'Hare Intl">
    <option value="Glasgow International">
    <option value="Edinburgh">
    <option value="Dubai International">
    <option value="New York JFK">
</datalist>

我将仅使用这6个机场.有什么方法可以实现它,使其在Safari浏览器中正常工作吗?

I will be using only these 6 airports. Is there any way to implement it so it works in Safari browser?

推荐答案

Safari 不支持 datalist.您可以改用 jQuery UI自动完成.该代码将类似于:

Safari does not support datalist. You could use jQuery UI Autocomplete Instead. The code will be something like :

$(function() {
  var availableTags = [
  "ActionScript",
  "AppleScript",
  "Asp",
  ];
  $( "#tags" ).autocomplete({
    source: availableTags
  });
});

其中#tags是输入元素的ID,availableTags是所需元素的列表.

where #tags is the ID of your input element and availableTags the list of elements you need.

这篇关于数据列表在Safari中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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