使用 javascript 关闭 iOS safari 选择器

发布于 2024-12-25 00:29:44 字数 345 浏览 2 评论 0原文

我正在寻找一种方法,在选择选项元素后关闭 iOS Safari 中的选择选择器。

我们可以用 OnChange 触发整个事情,但选择器仍然打开。

我尝试了 .blur().blur(function() { window.clearInterval(interval); })

我们正在安装 jQuery 的情况下运行。

该过程应该是:

  1. 用户点击选择框
  2. 选项出现在内置浏览器选择器中
  3. 用户点击选项
  4. 脚本加载
  5. 选择器随后消失(这是缺少的步骤)

I am looking for a way to dismiss the select picker found in the iOS Safari once a option element is being selected.

We can trigger the whole thing with OnChange, but the picker is still open.

I tried .blur() and .blur(function() { window.clearInterval(interval); })

We are running with jQuery installed.

The process should be :

  1. User taps the select box
  2. Options appear in the built-in browser picker
  3. User taps an option
  4. Script loads
  5. Picker goes away afterwards (this is the step missing)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

南城旧梦 2025-01-01 00:29:44

您可以将 onblur 事件处理程序绑定到输入元素,并检查处理程序中是否有任何元素具有焦点(使用 document.activeElement)。正如类似问题的答案<中给出的/a>.

You can bind the onblur event handler to the input elements and check in the handler if any of them have focus (using document.activeElement). As given in this answer to a similar question.

摘星┃星的人 2025-01-01 00:29:44

您可以尝试触发不需要选择器的事件。

$('#foo').trigger('点击');

还要确保您的事件处理程序返回 false。

You can try triggering an event which doesn't require the picker.

$('#foo').trigger('click');

Also make sure your event handlers return false.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文