0

I'm using script form this article https://stackoverflow.com/a/20060541/14723575

$(function(){
    var current = location.pathname;
    $('#nav li a').each(function(){
        var $this = $(this);
        // if the current path is like this link, make it active
        if($this.attr('href').indexOf(current) !== -1){
            $this.addClass('active');
        }
    })
})

The script works as it should when the pages are in the form: site.com/category site.com/category/subcategory etc, but the active class is lost when I want to go to the 2nd, 3rd etc. page via pagination, i.e. when the path is site.com/category/page/2/ site.com/category/page/3/ site.com/category/subcategory/page/2/ site.com/category/subcategory/page/3/ etc

What do I need to correct in the script so that the active class remains in the cases mentioned above ?

Majurac
  • 59
  • 1
  • 8

0 Answers0