title: Show/Hide HTML Menu
body: <p>I have a HTML Jquery menu bar which I have created, and I need to create a button to show and hide the menu.</p>
  
  <p>I am think that somehow I can use JQUERY also in this to show/hide the menu bar with a click of the menu button.</p>
  
  <p>The menu bar is like so
  <a href="http://codecanyon.net/theme_previews/2867525-jquery-dashboard-vertical-navigation?index=1" rel="nofollow">http://codecanyon.net/theme_previews/2867525-jquery-dashboard-vertical-navigation?index=1</a></p>
  
  <p>I am thinking I can somehow collapse all the buttons into the top icon? Is this possible?</p>
  
  <p><strong>HTML</strong>
      
      
      
          
          
          
          
          
          
      
      </p>
  
  <pre><code>&lt;div class="sidebar"&gt;
      &lt;div class="logo"&gt;
      &lt;/div&gt;
      &lt;ul&gt;
          &lt;li&gt;
              &lt;a href="#"&gt;Campaigns &lt;/a&gt;
              &lt;ul class="submenu"&gt;
                  &lt;li&gt;&lt;a href="#"&gt;Sub Menu1&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a href="#"&gt;Sub Menu2&lt;/a&gt;&lt;/li&gt;
              &lt;/ul&gt;
          &lt;/li&gt;
          &lt;li&gt;
              &lt;a href="#"&gt;Links &lt;/a&gt;
              &lt;ul class="submenu"&gt;
                  &lt;li&gt;&lt;a href="#"&gt;Sub Menu1&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a href="#"&gt;Sub Menu2&lt;/a&gt;&lt;/li&gt;
              &lt;/ul&gt;
          &lt;/li&gt;
          &lt;li&gt;
              &lt;a href="#"&gt;Media &lt;/a&gt;
              &lt;ul class="submenu"&gt;
                  &lt;li&gt;&lt;a href="#"&gt;Sub Menu1&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a href="#"&gt;Sub Menu2&lt;/a&gt;&lt;/li&gt;
              &lt;/ul&gt;
          &lt;/li&gt;
          &lt;li&gt;&lt;a href="#"&gt;History&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;
              &lt;a href="#"&gt;Messages &lt;/a&gt;           
              &lt;ul class="submenu"&gt;
                  &lt;li&gt;&lt;a href="#"&gt;Sub Menu1&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a href="#"&gt;Sub Menu2&lt;/a&gt;&lt;/li&gt;
              &lt;/ul&gt;
          &lt;/li&gt;
          &lt;li&gt;
              &lt;a href="#"&gt;Maintenance &lt;/a&gt;            
              &lt;ul class="submenu"&gt;
                  &lt;li&gt;&lt;a href="#"&gt;Sub Menu1&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a href="#"&gt;Sub Menu2&lt;/a&gt;&lt;/li&gt;
              &lt;/ul&gt;
          &lt;/li&gt;
      &lt;/ul&gt;
  &lt;/div&gt;
  
  &lt;div class="content"&gt;
      &lt;p&gt;Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh     euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim     veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea     commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse     molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et     iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te     feugait nulla facilisi. Nam liber tempor cum soluta nobis eleifend option congue nihil     imperdiet doming id quod mazim placerat facer possim assum. Typi non habent claritatem     insitam; est usus legentis in iis qui facit eorum claritatem. Investigationes     demonstraverunt lectores legere me lius quod ii legunt saepius. Claritas est etiam     processus dynamicus, qui sequitur mutationem consuetudium lectorum. Mirum est notare quam     littera gothica, quam nunc putamus parum claram, anteposuerit litterarum formas humanitatis     per seacula quarta decima et quinta decima. Eodem modo typi, qui nunc nobis videntur parum     clari, fiant sollemnes in futurum.&lt;/p&gt;
  &lt;/div&gt;
  
  &lt;script type="text/javascript"         src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript" src="js/custom.js"&gt;&lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>CSS</strong>
      html {
      height: 100%;
      }</p>
  
  <pre><code>body {
  margin:0;
  padding: 0;
  height: 100%;
  font-family: Arial;
  font-size: 12px;
  background: #f3f3f3;
  }
  
  *:focus {
  border: none;
  outline: none;
  }
  
  .content {
  padding: 25px 25px 25px 250px;
  }
  
  .logo {
  display: block;
  text-indent: -9999px;
  text-transform: capitalize;
  background: url(../images/logo.png) no-repeat;
  height: 90px;
  }
  
  .sidebar {
  height: 100%;
  min-height: 100%;
  width: 213px;
  background: url(../images/sidebarBg.png);
  box-shadow: 0 0 8px #999;
  float: left;
  position: absolute;
  top: 0;
  }
  
  /**  MENU  **/
  
  ul {
  margin: 0;
  padding: 0;
  list-style: none;
  }
  
  ul li {
  background: url(../images/listBg.png) bottom no-repeat;
  text-indent: 50px;
  }
  
  ul li a {
  color: white;
  display: block;
  text-decoration: none;
  padding: 21px;
  width: 170px;
  text-shadow: 1px 1px 0 #191b20;
  position:relative;
  }
  
  ul li:hover {
  background: url(../images/listBgGreen.png) no-repeat;
  }
  
  ul li a:hover, ul li:hover a {
  color: white;
  text-shadow: 1px 1px 0 #547829;
  }
  
  ul li a.dashboard {
  background: url(../images/iconDashboard.png) 25px 50% no-repeat;
  }
  
  ul li a.pages {
  background: url(../images/iconPages.png) 25px 50% no-repeat;
  }
  
  ul li a.media {
  background: url(../images/iconMedia.png) 25px 50% no-repeat;
  }
  
  ul li a.history {
  background: url(../images/iconHistory.png) 25px 50% no-repeat;
  }
  
  ul li a.messages {
  background: url(../images/iconMessages.png) 25px 50% no-repeat;
  }
  
  ul li a.settings {
  background: url(../images/iconSettings.png) 25px 50% no-repeat;
  }
  
  /**  SUB MENU  **/
  
  ul li ul.submenu {
  display: block;
  z-index: 500;
  top: 0;
  }
  
  ul li ul.submenu li {
  background: url(../images/subMenuBg.png) bottom no-repeat;
  }
  
  ul li ul.submenu li a {
  background: none;
  padding: 13px;
  width: 189px;
  }
  
  ul li ul.submenu li.last {
  border-bottom: 1px solid #54575b;
  background: url(../images/subMenuBg.png) top no-repeat;
  }
  
  ul li ul.submenu li.last a {
  padding: 12px;
  }
  
  ul li:hover ul.submenu li a {
  text-shadow: 1px 1px 0 black;
  }
  
  ul li ul.submenu li:hover {
  background: url(../images/subMenuBgHover.png) bottom no-repeat;
  }
  
  /**  PIPS  **/
  
  .pip {
  display: block;
  background: url(../images/pipBg.png);
  padding: 3px 12px;
  position: absolute;
  top: 20px;
  right: 25px;
  color: white;
  text-align: center;
  text-indent: 0;
  font-size: 10px;
  border-top: 1px solid #1c1f23;
  border-bottom: 1px solid #4c4f56;
  border-radius: 30px;
  -webkit-border-radius: 30px;
  -moz-border-radius: 30px;
  }
  
  ul li:hover .pip {
  background: url(../images/pipBgHover.png);
  border-top: 1px solid #547829;
  border-bottom: 1px solid #a4ce6b;
  
  }
  
  /**  SEARCH  **/
  
  .search {
  background: url(../images/listBg.png) no-repeat;
  padding: 18px 15px;
  width: 185px;
  height: 29px;
  }
  
  .search input {
  width: 125px;
  padding: 7px 7px 7px 35px;
  border:none;
  margin: 0 0 0 10px;
  background: #fff url(../images/search.png) 10px 50% no-repeat;
  color: #808080;
  
  box-shadow: inset 0 0 5px #ccc;
  -webkit-box-shadow: inset 0 0 5px #ccc;
  -moz-box-shadow: inset 0 0 5px #ccc;
  
  border-radius: 30px;
  -webkit-border-radius: 30px;
  -moz-border-radius: 30px;
  }
  </code></pre>
  
  <p><strong>Custom.js</strong></p>
  
  <pre><code>$(document).ready(function() {
  
  // Adds title attributes and classnames to list items
  
  $("ul li a:contains('History')").addClass("dashboard").attr('title', 'Dashboard');
  $("ul li a:contains('Links')").addClass("pages").attr('title', 'Pages');
  $("ul li a:contains('Media')").addClass("media").attr('title', 'Media');
  $("ul li a:contains('Campaigns')").addClass("history").attr('title', 'History');
  $("ul li a:contains('Messages')").addClass("messages").attr('title', 'Messages');
  $("ul li a:contains('Maintenance')").addClass("settings").attr('title', 'Settings');
  
  // Add class to last list item of submenu
  
  $("ul.submenu li:last-child").addClass("last");
  
  $("ul li:has(ul)").hover(function(){
      $(this).find("ul.submenu").stop("true", "true").slideDown(500);
      }, function(){
      $(this).find("ul.submenu").stop("true", "true").slideUp(500);
  });
  
  });
  </code></pre>
  
  <p>Hope this helps... Thanks</p>