How to highlight a menu item if the user is on the page that the menu item leads?

Need to work with the address of the current page. Can you tell me the scheme of such a mechanism?
June 3rd 19 at 19:20
2 answers
June 3rd 19 at 19:22
Solution
Something like this:
$('ul.menu > li a[href]').each(function() {
 if(this.href === window.location.toString())
$(this).addClass('active');
});
Thanks, I will try. - Coby_Veum commented on June 3rd 19 at 19:25
on this website there is a button "mark a solution" don't forget about it. It is very important. - shane.Legros commented on June 3rd 19 at 19:28
I know. Just as long as you got distracted by another task, and I used first finally come to the conclusion, and then to do something. But this decision does seem to be true, so now I note. - Coby_Veum commented on June 3rd 19 at 19:31
June 3rd 19 at 19:24
window.location.href and then compare with the link in the element and add a class or from the style. How you want to be

Find more questions by tags JavaScriptHTMLCSSjQuery