Este es un ejemplo que encontre, lo estoy pasando a javascript.
Creo que ya resolvi la parte del navbar, si tienen sugerencias o detectan errores lo apreciaria mucho.
Código
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <link rel="stylesheet" href="http://getbootstrap.com/dist/css/bootstrap.min.css"> <script> hasClass = function (el, cl) { var regex = new RegExp('(?:\\s|^)' + cl + '(?:\\s|$)'); return !!el.className.match(regex); } function hideMenu(ob){ var menuD = document.querySelector( ob.getAttribute('data-target') ); if( hasClass(menuD, 'in') ){ menuD.classList.remove('in'); menuD.style.display = 'none'; } } function hideSubMenu(ob){ var menuD = ob.parentNode; if( hasClass(menuD, 'open') ){ menuD.classList.remove('open'); } } function showMenu(e){ var ob = e.target; var menuD = document.querySelector( ob.getAttribute('data-target') ); if( hasClass(menuD, 'in') ){ menuD.classList.remove('in'); menuD.style.display = 'none'; } else { menuD.classList.add('in'); menuD.style.display = 'block'; } } function showSubMenu(e){ var ob = e.target; var menuD = ob.parentNode; if( hasClass(menuD, 'open') ){ menuD.classList.remove('open'); } else { menuD.classList.add('open'); } } </script> </head> <body> <nav id="myNavbar" class="navbar navbar-default navbar-inverse navbar-fixed-top" role="navigation"> <!-- Brand and toggle get grouped for better mobile display --> <div class="container"> <div class="navbar-header"> <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbarCollapse"> </button> </div> <!-- Collect the nav links, forms, and other content for toggling --> <div class="collapse navbar-collapse" id="navbarCollapse"> <ul class="nav navbar-nav"> <li class="dropdown"> <ul class="dropdown-menu" role="menu"> </ul> </li> <li class="dropdown"> <ul class="dropdown-menu" role="menu"> </ul> </li> </ul> </div> </div> </nav> <div class="container"> <div class="jumbotron"> <p>In today's world internet is the most popular way of connecting with the people. At <a href="http://www.tutorialrepublic.com" target="_blank">tutorialrepublic.com</a> you will learn the essential of web development technologies along with real life practice example, so that you can create your own website to connect with the people around the world.</p> </div> <div class="row"> <div class="col-sm-6 col-md-4 col-lg-2"> </div> <div class="col-sm-6 col-md-4 col-lg-2"> </div> <div class="col-sm-6 col-md-4 col-lg-2"> </div> <div class="col-sm-6 col-md-4 col-lg-2"> </div> <div class="col-sm-6 col-md-4 col-lg-2"> </div> <div class="col-sm-6 col-md-4 col-lg-2"> </div> </div> <hr> <div class="row"> <div class="col-sm-12"> <footer> </footer> </div> </div> </div> <script> document.addEventListener('click', function(e) { var oMenu = document.getElementById('collapse'); oMenu = document.querySelector('button.navbar-toggle'); if(e.target == oMenu ) showMenu(e); else if( hasClass(e.target, 'dropdown-toggle') ) showSubMenu(e); else { hideMenu( oMenu ); listaSub = document.getElementsByClassName('dropdown-toggle'); for (i= 0; i < listaSub.length; i++) { hideSubMenu(listaSub[i]); } /* Array.prototype.forEach.call(listaSub, function(el) { // Do stuff with the element hideSubMenu(el); });*/ } }); </script> </body> </html>
saludos.