更新时间:2023-01-06 18:11:53
看看:
$(document).ready(function () {
$(document).click(function (event) {
var clickover = $(event.target);
var _opened = $(".navbar-collapse").hasClass("navbar-collapse in");
if (_opened === true && !clickover.hasClass("navbar-toggle")) {
$("button.navbar-toggle").click();
}
});
});
您的小提琴适用于: http://jsfiddle.net/52VtD/5718/
它是这个回答,缺少动画和
我知道,调用 click()
不是很优雅,但是 collapse('hide')
对我来说也不行,我认为动画比添加和删除类稍微好一些。
I know, invoking the click()
isn't very elegant, but collapse('hide')
did not work for me either, and i think the animation is a bit nicer than adding and removing the classes hardly.