<div class="dropdown">
<button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenu2" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Dropdown
</button>
<div class="dropdown-menu" aria-labelledby="dropdownMenu2">
<button class="dropdown-item" type="button">Action</button>
<button class="dropdown-item" type="button">Another action</button>
<button class="dropdown-item" type="button">Something else here</button>
</div>
</div>
This will work for you.
I just added some extra CSS custom style to support your buttons
, this is needed because as default the style is supported for .dropdown-menu>li>a
that means the style will only support the a
tag inside the li
under the .dropdown-menu
, so what I did was - I just styled your button to the default style.
I have also added <span class="caret"></span>
to the Dropdown button and also added the class btn-primary
use this only if its needed. Hope this helps you.
$(document).ready(function() {
$(".dropdown-toggle").dropdown();
});
.dropdown-menu>button {
display: block;
padding: 3px 20px;
clear: both;
font-weight: 400;
line-height: 1.42857143;
color: #333;
white-space: nowrap;
width: 100%;
text-align: left;
background: #fff;
border: none;
}
.dropdown-menu>button:focus,
.dropdown-menu>button:hover {
color: #262626;
text-decoration: none;
background-color: #f5f5f5;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<div class="dropdown">
<button class="btn btn-primary dropdown-toggle" type="button" id="dropdownMenu2" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Dropdown <span class="caret"></span>
</button>
<div class="dropdown-menu" aria-labelledby="dropdownMenu2">
<button class="dropdown-item" type="button">Action</button>
<button class="dropdown-item" type="button">Another action</button>
<button class="dropdown-item" type="button">Something else here</button>
</div>
</div>