Bootstrap Tutorial - Link dropdown menu and tab content








The following code shows how to link dropdown menu and tab content.

Example

<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='http://code.jquery.com/jquery-1.9.1.js'></script>
<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://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/js/bootstrap.min.js"></script>
<script type='text/javascript'>//<![CDATA[ 
$(window).load(function(){<!-- w  w w. j av  a  2s.c om-->
$('a[data-toggle="tab"]').on('shown', function (e) {
    $('.dropdown-menu li.active').removeClass('active');
    $(this).parent('li').addClass('active');
})
});//]]>  
</script>
</head>
<body>
  <div class="" id="pills-basic">
    <div class="">
      <div class="btn-group">
        <a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
          Action <span class="caret"></span>
        </a>
        <ul class="dropdown-menu">
          <li><a href="#myID0" data-toggle="tab">myID0</a></li>
          <li><a href="#myID" data-toggle="tab">County</a></li>
          <li><a href="#myID2" data-toggle="tab">myID2 County</a></li>
          <li><a href="#myID4" data-toggle="tab">myID4 County</a></li>
        </ul>
      </div>
      <div class="tab-content">
        <div id="Home" class="tab-pane active">Some stuff.</div>
        <div id="myID" class="tab-pane">
          <div class="rnkw-lists" data-rnkw-width="100%"
            data-rnkw-height="1376" data-rnkw-id="930926"></div>
          <span href="">A</span>
        </div>
        <div id="myID4" class="tab-pane">
          <div class="rnkw-lists" data-rnkw-width="100%"
            data-rnkw-height="1510" data-rnkw-id="930947"></div>
          <span>B</span>
        </div>
        <div id="myID0" class="tab-pane">
          <div class="rnkw-lists" data-rnkw-width="100%"
            data-rnkw-height="1912" data-rnkw-id="931127"></div>
          <span>F</span>
        </div>
        <div id="myID2" class="tab-pane">
          <div class="rnkw-lists" data-rnkw-width="100%"
            data-rnkw-height="1711" data-rnkw-id="931546"></div>
          <span>J</span>
        </div>
      </div>
    </div>
  </div>
</body>
</html>

Click to view the demo