Bootstrap Tutorial - Toggle list items








The following code shows how to toggle list items.

Example

<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src="http://cdnjs.cloudflare.com/ajax/libs/jquery/1.8.3/jquery.js"></script>
<script type='text/javascript'
  src="http://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/2.2.2/bootstrap.min.js"></script>
<link rel="stylesheet" type="text/css"
  href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.2.2/css/bootstrap-combined.min.css">
<style type='text/css'>
.row-fluid>.sidebar {
  width: 280px;
  position: absolute !important;
  left: auto;
}<!--from ww  w.ja  v  a2  s.  c o  m-->
</style>
</head>
<body>
  <div class="container-fluid">
    <div class="row-fluid">
      <div class="sidebar">
        <div class="well sidebar-nav">
          <ul class="nav nav-list">
            <li class="nav-header">Header</li>
            <li class="divider"></li>
            <li>
            <a href="#" data-toggle="collapse" data-target="#toggle">Toggle</a>
            </li>
            <ul id="toggle" class="collapse out">
              <li><a href="#">Item A</a> 
              <span class="label pull-right">2</span></li>
              <li><a href="#">Item B</a> 
              <span class="label pull-right">1</span>
              </li>
            </ul>
          </ul>
        </div>
      </div>
    </div>
  </div>
</body>
</html>

Click to view the demo