ccurtin
5/28/2015 - 1:07 AM

Add and active class to a link within a conainer

Add and active class to a link within a conainer

// Add active '.current-cat' to currently active category filter <li> element
var linkList = document.querySelectorAll('.filter-categories a');
for (var i in linkList) {
    if (document.location.href.indexOf(linkList[i].href) >= 0) {
        linkList[i].parentNode.classList.add('current-cat');
    }
}



// exact match, BUT watchout for parent/child relational pages.
var linkList = document.querySelectorAll('.menu-container li a');
for (var i in linkList) {
console.log(linkList[i].href);
    if (document.location.href === linkList[i].href) {
        linkList[i].parentNode.classList.add('active');
    }
}