How to toggle a Bootstrap dropdown menu from a lin

2019-02-24 08:22发布

I have a Bootstrap dropdown menu that is working fine. What I'd like to do is also trigger the opening of the menu by clicking on a link elsewhere on the page. (This makes sense because of what's in the menu item, etc.) The doc page says that having the link do something like $('.dropdown-toggle').dropdown(), or maybe $('.dropdown-toggle').dropdown('toggle') should do this, but neither is working for me. Any suggestions?

1条回答
不美不萌又怎样
2楼-- · 2019-02-24 09:16

try

$(".dropdown").addClass("open");

and

$(".dropdown").removeClass("open");
查看更多
登录 后发表回答