Skip to content

Instantly share code, notes, and snippets.

@kohki-shikata
Created November 12, 2015 05:22
Show Gist options
  • Save kohki-shikata/6859ee7e2718c4e254c6 to your computer and use it in GitHub Desktop.
Save kohki-shikata/6859ee7e2718c4e254c6 to your computer and use it in GitHub Desktop.
jQuery add class current page navigation
// add class current page navigation
$(document).ready(function() {
var url = location.pathname;
if(location.pathname != "/") {
$('nav.subpage_sidebar a[href^="' + location.pathname + '"]').parent().addClass('active');
} else $('nav.subpage_sidebar a:eq(0)').parent().addClass('active');
//console.log(url);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment