Bootstrap Tutorial - Toggle dropdown with link








The following code shows how to toggle dropdown with link.

Example

<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css"
  href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css">
<script type='text/javascript'
  src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script type='text/javascript'
  src="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/js/bootstrap.min.js"></script>
<script type='text/javascript'>//<![CDATA[ 
window.onload=function(){<!--   w  w w.  j  a v a 2 s . c  om-->
$(function(){
    $(".dropdown-toggle").click(function(){
        $(this).dropdown('toggle');
    });
});  
}//]]>  
</script>
</head>
<body>
  <div class="dropdown">
    <a href="javascript:void(0)" class="dropdown-toggle">Dropdown 
       <b class="caret"></b>
    </a>
    <ul class="dropdown-menu">
      <li><a href="#">Action</a></li>
      <li><a href="#">Another action</a></li>
      <li><a href="#">Something here</a></li>
    </ul>
  </div>
</body>
</html>

Click to view the demo