Implementation of Bootstrap3 Drop down Menu
- 2021-07-22 09:04:49
- OfStack
Usage
Through the data attribute
<div class="dropdown">
<button id="dLabel" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Dropdown trigger
<span class="caret"></span>
</button>
<ul class="dropdown-menu" aria-labelledby="dLabel">
...
</ul>
</div>
Through JavaScript
$('.dropdown-toggle').dropdown()
data-toggle= "dropdown" is always required, whether through the data attribute or JavaScript
Method
$().dropdown('toggle')
Events
According to time, it is divided into show. bs. dropdown shown. bs. dropdown hide. bs. dropdown hidden. bs. dropdown
$('#myDropdown').on('show.bs.dropdown', function () {
// do something …
})