Nix Nix - 6 months ago 9
Javascript Question

How to get current_page_url to say active in jquery

I'm using laravel 5.2 and I'm trying to get my nav to say whether or not it is active. I've managed to do it so far but when I first land on my page the home link isn't set to active so what I'm trying to do is that if my current page is equal to the landing page then the home link must be active and if not then the home page link must not have the class active.

My js

var current_page_URL = location.href;
console.log(current_page_URL);
if(current_page_URL == '/'){
console.log("yes");
}else{
console.log("no");
}


I hope I made sense

Answer
var current_page_URL = location.href;
console.log(current_page_URL);
var home_page_URL = http://localhost/site/public/;
if(current_page_URL == home_page_URL){
    console.log("yes");
}else{
    console.log("no");
}

You want something like this?