How to open Bootstrap dropdown programmatically

后端 未结 16 1924
轮回少年
轮回少年 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:10

    You need to stop the click event from bubbling to parent elements

    $('#sidebar_filter_city li').click(function(e){   
        $('#sidebar_filter_areas').dropdown('toggle');
        e.stopPropagation();
    });
    

    You can also use return false; which will do the same thing, but this will also preventDefault on the click.

提交回复
热议问题