Last active
March 1, 2021 17:22
-
-
Save prappo/1b838efacf70277108e40029560e182d to your computer and use it in GitHub Desktop.
menu items active based on hash url
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery(document).ready(function() { | |
if (/Android|webOS|iPhone|iPad|Mac|Macintosh|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) { | |
function setActive() { | |
setTimeout(function() { | |
var hash = window.location.hash.substr(1); | |
if (hash) { | |
jQuery('[href*="#"]').removeClass('elementor-item-active'); | |
jQuery('[href*="' + hash + '"]').addClass('elementor-item-active'); | |
} | |
}, 15); | |
} | |
setActive(); | |
jQuery('[href*="#"]').click(function() { | |
var url = jQuery(this).attr('href'); | |
window.location.hash = url; | |
setActive(); | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment