Bootstrap Tutorial - Toggle dropdown from extended button








The following code shows how to toggle dropdown from extended button.

Example

<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='http://code.jquery.com/jquery-1.8.3.js'></script>
<link rel="stylesheet" type="text/css"
  href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.1.1/css/bootstrap-combined.min.css">
<script type='text/javascript'
  src="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.1.1/js/bootstrap.min.js"></script>
<script type='text/javascript'>
$(window).load(function(){<!--   w w w .  j a  va 2 s. c  o  m-->
    $('#action-btn').click(function(){
        console.log("Do Something");
    });
});
</script>
</head>
<body style='margin:30px'>
  <div class="btn-group">
    <button id="action-btn" class="btn btn-success">Recommend</button>
    <span class="btn btn-success dropdown-toggle" data-toggle="dropdown">&gt;</span>
    <ul class="dropdown-menu">
      <li><a href="#">Recoemmend me</a></li>
      <li><a href="#">Post to wall</a></li>
    </ul>
  </div>
</body>
</html>

Click to view the demo