So my problem is that I got a number of pages that I gather from my database and output in a echo. I then want to make a highlight which displays what pages you on.
I have managed by myself to make it highlight the selected page when you click it but I can't manage to get the index page to get highlighted when visiting for example
"www.test.com" I have to be on a page like this "www.test.com/index" for it to work. Hard to explain but I will show you my code and it might become more clearly.
$sqlmenu = mysql_query ("SELECT id, label FROM pages ORDER BY pageorder ASC");
var i = document.location.href.lastIndexOf("/");
var currentPHP = document.location.href.substr(i+1);
$("ul#main-menu li a").removeClass('activeNavBtn');
$("ul#main-menu li a[href^='"+currentPHP+"']").addClass('activeNavBtn');
01-24-2014, 12:08 PM
var currentPHP = document.location.href.substr(i+1)||'index.php';
01-24-2014, 12:20 PM
Thank you that helped alot!
Was the exact answer, forgot to say that "home" had a static number of 1...
but it was enough to make me figure it out so many thanks!!