使用 javascript 关闭 iOS safari 选择器
我正在寻找一种方法,在选择选项元素后关闭 iOS Safari 中的选择选择器。
我们可以用 OnChange 触发整个事情,但选择器仍然打开。
我尝试了 .blur()
和 .blur(function() { window.clearInterval(interval); })
我们正在安装 jQuery 的情况下运行。
该过程应该是:
- 用户点击选择框
- 选项出现在内置浏览器选择器中
- 用户点击选项
- 脚本加载
- 选择器随后消失(这是缺少的步骤)
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 :
- User taps the select box
- Options appear in the built-in browser picker
- User taps an option
- Script loads
- Picker goes away afterwards (this is the step missing)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以将 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.
您可以尝试触发不需要选择器的事件。
还要确保您的事件处理程序返回 false。
You can try triggering an event which doesn't require the picker.
Also make sure your event handlers return false.