javascript - 为什么 Bootstrap 按钮下拉菜单在 iOS 上不起作用?

标签 javascript html css twitter-bootstrap

看起来甚至是 bootstrap demo here不适用于 iOS。您似乎无法在 iPhone 或 iPad 上从中选择元素。

有解决办法吗?

最佳答案

github 上的许多问题评论中都提到了一个快速修复方法: https://github.com/twitter/bootstrap/issues/2975#issuecomment-8670606

将此脚本添加到您的关闭 html 标记之前:

$('body').on('touchstart.dropdown', '.dropdown-menu', function (e) { 
    e.stopPropagation(); 
});

我已经在 ios5 和 6 上测试了上述方法。它非常有效


如果您希望修改 Bootstrap javascript,您可以从文件底部附近的 clearMenus 的 html 绑定(bind)中删除 touchstart.dropdown.data-api,而不是上面的修复。

只是改变这个

$('html')
  .on('click.dropdown.data-api touchstart.dropdown.data-api', clearMenus)

对此

$('html')
  .on('click.dropdown.data-api', clearMenus)

关于javascript - 为什么 Bootstrap 按钮下拉菜单在 iOS 上不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12190783/

相关文章:

javascript - 调整 iframe 以加载内容

javascript - HTML textarea 值为 'undefined'

Javascript 表刷新没有 jquery

html - 如何为 fontawesome 图标提供固定大小

html - 如何设置mat-autocomplete中的元素数

jquery - 是否可以在鼠标悬停时在同一个超链接中打开 2 个链接

html - 使用 Nokogiri 替换所有出现的 CSS 类

javascript - 错误 : The Mongo server and the Meteor query disagree on how many documents match your query. 可能遇到了 Mongo 边界情况?查询是:{}

javascript - 如何在网络中的 vis.js 中添加背景图像

javascript - 工作灯 6.2 : Unable to add multiple js files in windows phone 8 environment