vendredi 30 janvier 2015

Add class to current page nav item


I have asked this before and I solved it then, but it won't apply again.


On this page (http://ift.tt/163m5UZ) I have a nav with a ul inside as the navigation bar, and I want to change the style of the current ul. Each link inside the li's have a class of the respective name.


I tried



$(document).ready(function() {
if ('http://ift.tt/163m5UZ' == window.location.href) {
$('.all').addClass("active");
}
});


and in the css I just added what I wanted to .active .


That didn't work so I tried this



if (window.location.href == "http://ift.tt/163TOxB") {
$("#trend").css({
'color': '#333',
'background-color': '#fff',
'opacity': '1',
});
}


Which was the one that worked on my other blog (http://ift.tt/163TMWy) But nothing seems to work now, any ideas?





Aucun commentaire:

Enregistrer un commentaire