SHARE
TWEET

Untitled

a guest Apr 4th, 2018 81 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. init();
  2.  
  3. function init() {
  4.     hideMobileNavOnClick();
  5. }
  6.  
  7. function hideMobileNavOnClick() {
  8.     var $ = jQuery,
  9.         menu = $('.main-navigation'),
  10.         inlineLinks = menu.find('a[href*="#"]');
  11.  
  12.     if (inlineLinks.length !== 0) {
  13.         inlineLinks.each(function() {
  14.             var link = $(this),
  15.                 linkHref = link.attr('href'),
  16.                 linkHash = linkHref.substr(linkHref.indexOf("#")),
  17.                 // Search ID or Name attributes
  18.                 target = $(linkHash).add('[name="' + linkHash.substr(1) + '"]');
  19.  
  20.             if (target.length !== 0) {
  21.  
  22.                 link.on('click', function(event) {
  23.                     var menuBtn = menu.find('.menu-toggle');
  24.  
  25.                     // If mobile
  26.                     if (!menuBtn.is(':hidden')) {
  27.                         // Hide the menu
  28.                         menuBtn.click();
  29.                     }
  30.  
  31.                 });
  32.             }
  33.         });
  34.     }
  35. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top