bootstrap 下拉按钮从其他按钮触发
bootstrap dropdown button trigger from other button
我正在尝试从另一个按钮触发下拉按钮,但似乎无法正常工作。
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');
});
});
将 stopPropagation
添加到您的按钮点击。
我正在尝试从另一个按钮触发下拉按钮,但似乎无法正常工作。 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');
});
});
将 stopPropagation
添加到您的按钮点击。