H
H
HOPMNC EVER2018-03-01 18:16:44
css
HOPMNC EVER, 2018-03-01 18:16:44

How to style active site categories?

Hello.
There are categories on the site.
For example:
1. Vegetables
1.1 Cucumber
1.2 Tomato
2. Fruits
2.1 Apples 2.2
Pears
Not a category.
In JS I would do this:

let veget = document.querySelector('.veget'),
       fruit = document.querySelector('.fruit');

 if(window.location.pathname == "/tomato/") {
  veget.classList.add('active');
}

How correct is this implementation?
I think you get the gist.
Thanks in advance for your replies

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Shamanov, 2018-03-01
@SilenceOfWinter

You need to pass breadcrumbs the path to the section in js and check the existing internal links for being in breadcrumbs.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question