这变得很烦人--当我点击Bootstrap下拉菜单中的一个项目时,下拉菜单没有关闭.我将其设置为当您单击下拉项时打开Facebox Lightbox,但它有一个问题.

enter image description here


我试过的

单击项目时,我try 了以下操作:

    $('.dropdown.open').removeClass('open');
    $('.dropdown-menu').hide();

That hides it, but then for some reason it won't open again.

As you can see I really need the dropdown to close, because it looks crappy when it stays open (mainly because the z-index of the dropdown is higher than the Facebox modal box overlay.


为什么我不使用Bootstrap的内置模式框

如果你想知道我为什么不使用漂亮的模态盒子built into Bootstrap,那是因为:

  1. It doesn't have a way to load content into it with AJAX.
  2. You have to type HTML each time for the modal; with Facebox you can do a simple: $.facebox({ajax:'/assets/ajax/dialogs/dialog?type=block-user&id=1234567'});
  3. It uses CSS3 animations to animate (which looks very nice) but in non-CSS3 browsers it just shows, which doesn't look that nice; Facebox uses JavaScript to fade in so it works in all browsers.

推荐答案

Try this:

$('.dropdown.open .dropdown-toggle').dropdown('toggle');

This may also work for you:

$('[data-toggle="dropdown"]').parent().removeClass('open');

Jquery相关问答推荐

jquery克隆div并将其附加在特定div之后

寻找 jQuery 事件类型的完整列表

将 HTML5 Canvas 转换为要上传的文件?

对自定义属性执行客户端验证

这些 jQuery 就绪函数之间有什么区别?

可以在不使用for=id的情况下将标签与复选框相关联吗?

页面滚动后,jQuery可拖动在错误的位置显示助手

如何使div全屏?

jQuery $.cookie 不是一个函数

如何从表格单元格 (td) 中获取相应的表格标题 (th)?

jQuery Force 为 iframe 设置 src 属性

使用 jQuery 获取选定的选项 id

用 Javascript 加载 jQuery 并使用 jQuery

从 Select 元素中获取选定的选项

如何使用 javascript (jquery) 将整数值添加到返回字符串的值中?

如何使用 jQuery 或纯 JS 重置所有复选框?

jQuery 发送字符串作为 POST 参数

D3 和​​ jQuery 有什么区别?

jQuery 使用 AND 和 OR 运算符按属性 Select

IE 中带有 jQ​​uery ajax 调用的无传输错误