Created
March 14, 2016 08:30
-
-
Save torounit/d3aaabd9cf59cc0da5bf to your computer and use it in GitHub Desktop.
今更感有るけど、現在のページやその親に対して、is-active をつける
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
$(function(){ | |
"use strict"; | |
$(".nav-menu a").each(function(){ | |
let href = this.href.replace(/\/$/, ""); | |
let currentURL = location.href.replace(/\/$/, ""); | |
if( href == location.origin ) { | |
if( currentURL == href ){ | |
$(this).addClass("is-active"); | |
} | |
}else { | |
if( currentURL.indexOf(href) > -1 ) { | |
$(this).addClass("is-active"); | |
} | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment