Bootstrap Tutorial - Create button with dropdown








The following code shows how to create button with dropdown.

Example

<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='http://code.jquery.com/jquery-git2.js'></script>
<link rel="stylesheet" type="text/css"
  href="http://netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css">
<script type='text/javascript'
  src="http://netdna.bootstrapcdn.com/bootstrap/3.0.3/js/bootstrap.min.js"></script>
</head><!--  w w  w  .  ja va  2s .  c  o  m-->
<body>
  <div class="container">
    <div class="row">
      <div class="col-sm-3">
        <div class="panel panel-default">
          <div class="panel-body">
            <div class="btn-group">
              <button type="button" class="btn btn-default dropdown-toggle"
                data-toggle="dropdown">
                <span data-bind="label">Select One</span>&nbsp;<span
                  class="caret"></span>
              </button>
              <ul class="dropdown-menu" role="menu">
                <li><a href="#">Item 1</a></li>
                <li><a href="#">Another item</a></li>
                <li><a href="#">This is a longer item</a></li>
              </ul>
            </div>
          </div>
        </div>
      </div>
    </div>
</body>
</html>

Click to view the demo