How to make active link falls inside?

I need the active link to change color when clicking and was active.
As well you need that for example to the path /admin is added to /admin/dashboard link remains active.
Example on codepen does not work because of the lack of pages in my version, but I think You will understand.

Here is an example
March 23rd 20 at 19:24
2 answers
March 23rd 20 at 19:26
Before you go here, you should watch the documentation.

a:link, a:visited { 
 color: (internal value);
 text-decoration: underline;
 cursor: auto;

a:link:active, a:visited:active { 
 color: (internal value);
I probably not clearly described the task will not be an option.
I need a solution using js.
when the page loads that would have been the active link by default.
during the transition to the other, with the previous links, the active class is removed and clung on current link.
exactly how to do it - I know. but if I let the admin/dashboard and not just /admin, then nothing works. as to the url is added to the path and I got to test just this.pathname == window.location.pathname - Juliet_Kuhlman commented on March 23rd 20 at 19:29
March 23rd 20 at 19:28
Thought of) to check this.pathname.split('/')[2] == window.location.pathname.split('/')[2] resolved the issue.

Find more questions by tags HTMLjQueryJavaScript