I was wondering if it would be possible to get the page name from the address bar using jquery or javascript. I know this can be done using PHP but don\'t really want to as
Current page: The single line sound more elegant to find the current page's file name:
location.href.split("/").slice(-1)
or
location.pathname.split("/").slice(-1)
This is cool to customize nav box's link, so the link toward the current is enlighten by a CSS class.
JS:
$('.menu a').each(function() {
if ($(this).attr('href') == location.href.split("/").slice(-1)){ $(this).addClass('curent_page'); }
});
CSS:
a.current_page { font-size: 2em; color: red; }