twitter bootstrap dropdown doesn't toggle closed when it should

后端 未结 8 1052
伪装坚强ぢ
伪装坚强ぢ 2021-02-10 00:16

Oh man, I\'ve been tearing my hair out over this. 4 hours on a dropdown.

I\'m using Twitter Bootstrap.

The fixed nav at the top has a dropdown, pretty standard s

8条回答
  •  旧时难觅i
    2021-02-10 00:57

    you can remove the "open" class from dropdown menus when another is clicked. this worked for me so far:

    $(document).ready(function () {
        $('a.dropdown-toggle').each(function(){
            $(this).on("click", function () {
                $('li.dropdown').each(function () {
                    $(this).removeClass('open');
                });
            });
        });
    });
    

提交回复
热议问题