Bootstrap Tutorial - Slide down/up dropdown








The following code shows how to slide down/up dropdown.

Example

<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='http://code.jquery.com/jquery-1.10.1.js'></script>
<link rel="stylesheet" type="text/css"
  href="http://netdna.bootstrapcdn.com/bootstrap/3.0.2/css/bootstrap.min.css">
<script type='text/javascript'
  src="http://netdna.bootstrapcdn.com/bootstrap/3.0.2/js/bootstrap.min.js"></script>
<script type='text/javascript'>
$(window).load(function(){<!--from www.  ja  v a 2s .co  m-->
    $(document).ready(function(){
      $('.dropdown').on('show.bs.dropdown', function(e){
        $(this).find('.dropdown-menu').first().stop(true, true).slideDown();
      });
      $('.dropdown').on('hide.bs.dropdown', function(e){
        $(this).find('.dropdown-menu').first().stop(true, true).slideUp();
      });
    });
});
</script>
</head>
<body>
  <div id="netsec_menu" class="row" style="width: 100%;">
    <div class="navbar netsec_navbar">
      <div class="container">
        <nav class="navbar-default netsec_navbar-default" role="navigation">
          <!-- Toggle button for mobile display -->
          <div class="navbar-header">
            <button type="button" class="navbar-toggle netsec_navbar-toggle"
              data-toggle="collapse" data-target="#netsec_mainmenu">
              <span class="sr-only">Toggle navigation</span> 
              <span class="icon-bar"></span> 
              <span class="icon-bar"></span> 
              <span class="icon-bar"></span>
            </button>
          </div>
          <!-- Menu Content -->
          <div class="collapse navbar-collapse" id="netsec_mainmenu">
            <ul class="nav navbar-nav netsec_menucontent">
              <li class="dropdown"><a href="#" class="dropdown-toggle"
                data-toggle="dropdown">DropDown Menu <b class="caret"></b></a>
                <ul class="dropdown-menu">
                  <li><a href="#">Sub-Item 1</a></li>
                  <li><a href="#">Sub-Item 2</a></li>
                  <li><a href="#">Sub-Item 3</a></li>
                  <li><a href="#">Sub-Item 4</a></li>
                  <li><a href="#">Sub-Item 5</a></li>
                  <li><a href="#">Sub-Item 6</a></li>
                </ul></li>
              <li><a href="#">Nav Item</a></li>
              <li><a href="#">Nav Item</a></li>
              <li><a href="#">Nav Item</a></li>
              <li><a href="#">Nav Item</a></li>
              <li><a href="#">Nav Item</a></li>
            </ul>
          </div>
        </nav>
      </div>
    </div>
  </div>
</body>
</html>

Click to view the demo