twitter-bootstrap 在 Bootstrap 中使用 show.bs.dropdown 的过程
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21857779/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Process for using show.bs.dropdown in Bootstrap
提问by Blake Stoddard
What is the process for using the show.bs.dropdownevent when a dropdown is clicked?
show.bs.dropdown单击下拉列表时使用事件的过程是什么?
Example:
例子:
When I clicked the dropdown to expand, it needs to run the code:
当我点击下拉菜单展开时,它需要运行代码:
$('#myDropdown').on('show.bs.dropdown', function () {
// do something…
})
回答by Zim
The Bootstrap dropdown showevent is tied to the parent element of the dropdown. For example, notice the id=myDropdown..
Bootstrap 下拉show事件与下拉列表的父元素相关联。例如,注意id=myDropdown..
<div class="btn-group" id="myDropdown">
<a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
Menu
<span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li><a href="#">Choice1</a></li>
<li><a href="#">Choice2</a></li>
<li><a href="#">Choice3</a></li>
<li class="divider"></li>
<li><a href="#">Choice..</a></li>
</ul>
</div>
Is handled by this event..
由这个事件处理..
$('#myDropdown').on('show.bs.dropdown', function () {
alert('hello');
})

