Answer the question
In order to leave comments, you need to log in
How to make an active link in the main menu?
Please tell me how you do the following:
There is a main menu for example: News, Blogs, Contacts... when you click on these links, pages open and this link changes (color, background, any other style). How to pass the name of the class or menu item that needs to change the css style. How do you do it?
PS Using asp.net mvc
Answer the question
In order to leave comments, you need to log in
If I understand correctly, you want to change the css class of the link leading to the page the user is currently on.
I do it with javascript and jquery this way:
$(document).ready(function(){
$("a[href='" + window.location.pathname + "']").addClass('active');
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question