https://i.stack.imgur.com/Q9OMB.png
Here's a little problem of mine. Basically I'm doing a theme for Ghost CMS but I've ran into a problem that has been bugging me for a few hours now and I can't solve this myself and haven't found a source of same kind of problem from google/sof neither.
My goal is to make a active page styling with different styles per page(home being red, about being blue etc) using jquery as I couldn't accomplish it in Ghost itself because it wants to rotate a single loop with same styles for all links.
Jquery Code so far
$(function(){
$('a').each(function() {
if ($(this).prop('href') == window.location.href) {
$(this).addClass('homeCurrent');}
});
});
Relevant HTML of navbar
<ul class= "nav navbar-nav navbar-left">
<li id="home" class="home hvr-sweep-to-top-home "><a href="/">Home</a></li>
<li id="about" class="about hvr-sweep-to-top-about"><a href="/page-about/">About</a></li>
</ul>
I've tried running different kinds of IF-statements with jquery but without success.
The logic of the code would go like :
if page is home = li style is homeCurrent
<ul class= "nav navbar-nav navbar-left">
<li id="home" class="home hvr-sweep-to-top-home homeCurrent"><a href="/">Home</a></li>
<li id="about" class="about hvr-sweep-to-top-about "><a href="/page-about/">About</a></li>
</ul>
if page is about = li style is aboutCurrent
<ul class= "nav navbar-nav navbar-left">
<li id="home" class="home hvr-sweep-to-top-home"><a href="/">Home</a></li>
<li id="about" class="about hvr-sweep-to-top-about aboutCurrent"><a href="/page-about/">About</a></li>
</ul>
Anyone?
Hopefully I included everything relevant.