How to make active link in the main menu?

Please tell me how you do the following:
Is the main menu for example: news, Blogs, Contacts,... clicking on these links will open the page and the link changes (color, background, any other style). How to pass class name or menu item which you want to change the css style. How do you do it?

PS Using mvc
September 26th 19 at 07:20
1 answer
September 26th 19 at 07:22
If I understand correctly, you want to change the css class the link to the page where you currently reside.
I do this with javascript and jquery this way:
 $("a[href='" + window.location.pathname + "']").addClass('active');
Yes this is what mean, the very use of jquery, just think maybe there are some other options and this something not quite right that, if, for example, and if there is on this page that such a link where the text of the article. - Vincent_Moore0 commented on September 26th 19 at 07:25
This can be easily avoided if you add a selector to the condition that this element must be a child of something with the id menu, for example. - Aimee59 commented on September 26th 19 at 07:28

Find more questions by tags ASP.NETC#MVC