Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- init();
- function init() {
- hideMobileNavOnClick();
- }
- function hideMobileNavOnClick() {
- var $ = jQuery,
- menu = $('.main-navigation'),
- inlineLinks = menu.find('a[href*="#"]');
- if (inlineLinks.length !== 0) {
- inlineLinks.each(function() {
- var link = $(this),
- linkHref = link.attr('href'),
- linkHash = linkHref.substr(linkHref.indexOf("#")),
- // Search ID or Name attributes
- target = $(linkHash).add('[name="' + linkHash.substr(1) + '"]');
- if (target.length !== 0) {
- // Enable keyboard support
- target.attr('tabindex', '-1');
- link.on('click', function(event) {
- var menuBtn = menu.find('.menu-toggle');
- // If mobile
- if (!menuBtn.is(':hidden')) {
- // Hide the menu
- menuBtn.click();
- }
- });
- }
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement