title: Function JavaScript : on Menu CSS HTML
body: <p>I have problems with my menu. Currently, it's only working on the submenu dropdown. </p>
  
  <p>How to enable it on the main menu too?</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>document.addEventListener('click', function(e) {
    e = e || window.event;
    var target = e.target || e.srcElement;
    if (target.parentElement.className.indexOf('has-submenu') &gt; -1) {
      e.target.classList.toggle('open');
    }
  }, false);</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>#menu {
    background: #343434;
    color: #eee;
    height: 35px;
    border-bottom: 4px solid #eeeded
  }
  
  #menu ul,
  #menu li {
    margin: 0 0;
    padding: 0 0;
    list-style: none
  }
  
  #menu ul {
    height: 35px
  }
  
  #menu li {
    float: left;
    display: inline;
    position: relative;
    font: bold 12px Arial;
    text-shadow: 0 -1px 0 #000;
    border-right: 1px solid #444;
    border-left: 1px solid #111;
    text-transform: uppercase
  }
  
  #menu li:first-child {
    border-left: none
  }
  
  #menu a {
    display: block;
    line-height: 35px;
    padding: 0 14px;
    text-decoration: none;
    color: #eee;
  }
  
  #menu li:hover &gt; a,
  #menu li a:hover {
    background: #111
  }
  
  #menu input {
    display: none;
    margin: 0 0;
    padding: 0 0;
    width: 80px;
    height: 35px;
    opacity: 0;
    cursor: pointer
  }
  
  #menu label {
    font: bold 30px Arial;
    display: none;
    width: 35px;
    height: 36px;
    line-height: 36px;
    text-align: center
  }
  
  #menu label span {
    font-size: 12px;
    position: absolute;
    left: 35px
  }
  
  #menu ul.menus {
    height: auto;
    width: 180px;
    background: #111;
    position: absolute;
    z-index: 99;
    display: none;
    border: 0;
  }
  
  #menu ul.menus li {
    display: block;
    width: 100%;
    font: 12px Arial;
    text-transform: none;
  }
  
  #menu li:hover ul.menus {
    display: block
  }
  
  #menu a.home {
    background: #c00;
  }
  
  #menu a.prett {
    padding: 0 27px 0 14px
  }
  
  #menu a.prett::after {
    content: "";
    width: 0;
    height: 0;
    border-width: 6px 5px;
    border-style: solid;
    border-color: #eee transparent transparent transparent;
    position: absolute;
    top: 15px;
    right: 9px
  }
  
  #menu a.prett.open::after {
    content: "";
    width: 0;
    height: 0;
    border-width: 6px 5px;
    border-style: solid;
    border-color: transparent transparent #eee transparent;
    position: absolute;
    top: 9px;
    right: 9px
  }
  
  #menu ul.menus a:hover {
    background: #333;
  }
  
  #menu ul.menus .submenu {
    display: none;
    position: absolute;
    left: 180px;
    background: #111;
    top: 0;
    width: 180px;
  }
  
  #menu ul.menus .submenu li {
    background: #111;
  }
  
  #menu ul.menus .has-submenu a.open ~ .submenu {
    display: block;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;nav&gt;
    &lt;ul id='menu'&gt;
      &lt;li&gt;&lt;a class='home' href='/'&gt;Home&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a class='prett' href='#' title='Menu'&gt;Menu&lt;/a&gt;
        &lt;ul class='menus'&gt;
          &lt;li class='has-submenu'&gt;&lt;a class='prett' href='#' title='Dropdown 1'&gt;Dropdown 1 + Sub Menu&lt;/a&gt;
            &lt;ul class='submenu'&gt;
              &lt;li&gt;&lt;a href="#" title="Sub Menu"&gt;Sub Menu&lt;/a&gt;&lt;/li&gt;
              &lt;li&gt;&lt;a href="#" title="Sub Menu"&gt;Sub Menu 2&lt;/a&gt;&lt;/li&gt;
              &lt;li&gt;&lt;a href="#" title="Sub Menu"&gt;Sub Menu 3&lt;/a&gt;&lt;/li&gt;
            &lt;/ul&gt;
          &lt;/li&gt;
          &lt;li&gt;&lt;a href='#' title='Dropdown 2'&gt;Dropdown 2&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href='#' title='Dropdown 3'&gt;Dropdown 3&lt;/a&gt;&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/nav&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>Fiddle: <a href="http://jsfiddle.net/thepio/pn0ym10e/2/" rel="nofollow">http://jsfiddle.net/thepio/pn0ym10e/2/</a></p>