我正试图从另一个按钮触发下拉按钮,似乎无法让它工作。 jsfiddle
<button type="button" class="btn btn-primary" id="btnFilter">Action</button>
<button type="button" id="btntest" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="false" style="display:none;">Action <span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu">
<li><a href="#">Action</a>
</li>
<li><a href="#">Another action</a>
</li>
<li><a href="#">Something else here</a>
</li>
<li class="divider"></li>
<li><a href="#">Separated link</a>
</li>
</ul>
JS
$(function(){
$('#btnFilter').on('click', function(){
$("#btntest").trigger('click');
});
});