Ackbar Ackbar - 2 months ago 14
CSS Question

Add css class in next page after follow link (asp.net-mvc razor)

I have the drop-down menu on jQuery. I need activate menu item and submenu item in next page after follow link.
Before:

<div class="menu__item">Menu Item 1</div>
<div class="menu__item__submenu">
@Html.ActionLink("Submenu item 1", ..., new { @class = "submenu__item" })


After:

<div class="menu__item menu__item-active">Menu Item 1</div>
<div class="menu__item__submenu submenu-active-js">
@Html.ActionLink("Submenu item 1", ..., new { @class = "submenu__item submenu__item-active" })


How i can make it?

Answer Source

It is just example not perfect code. you need to customization as per your code.

like:

switch (window.location.pathname) {
    case '/technology':
        $('#main').addClass('tech')
    case '/something':
    case '/somestuff':
        $('#main').addClass('some')
}