单击链接时,Bootstrap切换不起作用 [英] Bootstrap toggle doesn´t work when a link is clicked

查看:282
本文介绍了单击链接时,Bootstrap切换不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当窗口大小调整时,右侧的导航栏会折叠,但当单击切换按钮时,菜单会出现。当我点击任何链接时,酒吧不会不切换......任何人都可以帮助我?

The navbar on the right collapses when the window is resized, but when I click the toggle button the menu appears. When I click any link, the bar doesn´t "un-toggle"... Can anybody help me?

网站 here 解决方案

Site here

单击链接时菜单折叠不是带引导程序的展开/折叠菜单的默认功能。如果您希望它以这种方式运行,则必须将隐藏功能 .collapse('hide')绑定到这些链接的点击操作。

Having the menu collapse when a link is clicked is not the default functionality of the expand/collapse menu with bootstrap. If you want it to function that way, you have to bind the hide function .collapse('hide') to the click action for those links.

你可以这样做:

You can do so by including this:

jQuery(function($){
    $('.navbar-default .navbar-nav > li > a').click(function() {
        $('.navbar-default .navbar-collapse').collapse('hide')
    });
});

这篇关于单击链接时,Bootstrap切换不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆