单击时 Bootstrap 下拉菜单关闭 [英] Bootstrap dropdown closing when clicked
本文介绍了单击时 Bootstrap 下拉菜单关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我将一个表单放在引导程序下拉列表中,但是当我单击表单中的任何字段时,下拉列表消失了.我有这段代码,但我不知道把它放在哪里以防止下拉菜单消失.
I put a form inside a bootstrap dropdown, but when I click any of the fields in the form, the dropdown goes away. I have this piece of code but I don't know where to put it to prevent the dropdown disappearing.
$(function test() {
// Setup drop down menu
$('.dropdown-toggle').dropdown();
// Fix input element click problem
$('.dropdown input, .dropdown label').click(function(e) {
e.stopPropagation();
});
});
谁能告诉我应该把它放在哪里?我在引导下拉菜单中尝试过,我在 HTML 中尝试过,但它仍然不起作用.
Could someone please tell me where I should put this? I tried in the bootstrap-dropdown, I tried within the HTML but it still doesn't work.
推荐答案
只需使用此示例.此解决方案适用于我.
Simply use this example.This solution works for me.
<script type="text/javascript">
window.addEvent('domready',function() {
Element.prototype.hide = function() {
$(function () {
// replace your tab id with myTab
//<ul id="myTab" class="nav nav-tabs">
$('#myTab li:eq(1) a').tab('show');
});
};
});
</script>
希望它会有所帮助.谢谢.
Hope it'll help. Thanks.
这篇关于单击时 Bootstrap 下拉菜单关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文