简体   繁体   English

bootstrap下拉按钮:如何在单击页面的其他部分时隐藏下拉菜单?

[英]bootstrap dropdown button: How to hide dropdown menu when click other part of page?

http://twitter.github.com/bootstrap/components.html#buttonDropdowns http://twitter.github.com/bootstrap/components.html#buttonDropdowns

See the above link, when the dropdown-menu is shown, the outer div with btn-group will automatically add a class "open", when i click other part of the page, the "open" class is removed so the dropdown-menu disappears. 看到上面的链接,当显示dropdown-menu ,带有btn-group的外部div会自动添加一个“打开”类,当我点击页面的其他部分时,“open”类被删除所以下拉菜单消失。

My question is how to impl "click other part of page so the "open" class is removed? 我的问题是how to impl "click other part of page so the "open" class is removed?

You can use a simple JavaScript to reset: 您可以使用简单的JavaScript重置:

$("body").click(function(){
    $(".open").removeClass("open");
});

I don't understand why you are asking this question, because, this is handled by BootStrap itself. 我不明白你为什么要问这个问题,因为这是由BootStrap本身处理的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM