How to open Bootstrap dropdown programmatically

后端 未结 16 1919
轮回少年
轮回少年 2020-12-01 13:56

I\'m trying to open a Bootstrap dropdown when I click a item of another dropdown.

The idea is to select a city from the first drop down - then the script will auto o

16条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-01 14:04

    Something I like to use that has a bit more user-expected behavior:

    if(!$('#myDropdown').hasClass('show')){
      $('#myDropdown').dropdown('toggle');
    }
    

    If it is already open, don't do anything. If it is closed, then it should open.

提交回复
热议问题