Created
April 11, 2020 18:34
-
-
Save BryanBarrera/a62915d25bc487c15c4373889fa83ccf to your computer and use it in GitHub Desktop.
If URL matches HREF, add Class
This file contains hidden or 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
if ( ('.element').length ) { | |
var url = window.location.pathname; | |
$('.element a').each(function() { | |
var href = $(this).attr('href'); | |
if (url.indexOf(href) > -1) { | |
jQuery(this).parent().addClass('is-active'); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment