• Home
  • About
  • Services
  • Gallery
  • Contact
Collect from
// The function to change the class var changeClass = function (r,className1,className2) { var regex = new RegExp("(?:^|\\s+)" + className1 + "(?:\\s+|$)"); if( regex.test(r.className) ) { r.className = r.className.replace(regex,' '+className2+' '); } else{ r.className = r.className.replace(new RegExp("(?:^|\\s+)" + className2 + "(?:\\s+|$)"),' '+className1+' '); } return r.className; }; // Creating our button in JS for smaller screens var menuElements = document.getElementById('menu'); menuElements.insertAdjacentHTML('afterBegin',''); // Toggle the class on click to show / hide the menu document.getElementById('menutoggle').Onclick= function() { changeClass(this, 'navtoogle active', 'navtoogle'); } document.Onclick= function(e) { var mobileButton = document.getElementById('menutoggle'), buttOnStyle= mobileButton.currentStyle ? mobileButton.currentStyle.display : getComputedStyle(mobileButton, null).display; if(buttOnStyle=== 'block' && e.target !== mobileButton && new RegExp(' ' + 'active' + ' ').test(' ' + mobileButton.className + ' ')) { changeClass(mobileButton, 'navtoogle active', 'navtoogle'); } }

Copyright © 2014.Company name All rights reserved.More Templates - Collect from