且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

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

更新时间:2023-01-15 21:44:21

有一个快速修复,在github的很多问题评论中指出:
https://github.com/twitter/bootstrap/issues/2975#issuecomment-8670606

There is a quick fix as noted in many of the issue comments on github: https://github.com/twitter/bootstrap/issues/2975#issuecomment-8670606

在你的关闭html标签之前添加这个脚本:

add this script just before your close html tag:

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

我在ios5和6上测试了上面的方法。它像一个charm

I have tested the above method on both ios5 and 6. It works like a charm

如果你想修改bootstrap的javascript,你可以,而不是上面的修复,删除touchstart.dropdown.data-api从

If you wish to modify the bootstrap javascript you could, instead of the fix above, remove touchstart.dropdown.data-api from the html binding for clearMenus near the bottom of the file.

只要更改

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

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