Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8290431
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T12:48:45+00:00 2026-06-08T12:48:45+00:00

i’m having some trouble. I’m doing an asp.net mvc3 application and i downloaded some

  • 0

i’m having some trouble.
I’m doing an asp.net mvc3 application and i downloaded some css menu, the thing is i want to keep the menu active after menu tab its clicked and only change when another one is clicked.

here’s the code of the menu on _Layout.cshtml

<nav>
<div class="cssmenu">
                <ul>
                    <li class='active'><span>@Html.ActionLink("Início", "Index", "Home")</span></li>
                    <li><span>@Html.ActionLink("Tarefas Contabilidade", "SelectEmpresa", "Empresa")</span></li>
                    <li><a href='#'><span>Clientes</span></a>
                        <ul>
                            <li><span>@Html.ActionLink("Listar clientes", "ListarEmpresas", "Empresa")</span></li>
                           </ul>
                    </li>
                     <li><a href='#'><span>Balancetes</span></a>
                        <ul>
                            <li><span>@Html.ActionLink("Listar registos", "ListaBalancetesPorSalaoMes", "Balancete")</span></li>
                        </ul>
                    </li>
                    <li><span>@Html.ActionLink("Sobre", "About", "Home")</span></li>
</ul>
 </div>
        </nav>

and i have this script:

 <script type="text/javascript">

                    $("li").click(function () {
                        $("li").removeClass("active");
                        $(this).addClass("active");

                    });
</script>

the first tab that i put there class= “active” works, but the script doesn’t seem to work when i click another menu tab, it only shows the first one active
a little help please 🙂

UPDATED

This is the rendered html:

           <nav>

           <div class="cssmenu">

                <ul>

                    <li><span><a href="/">In&#237;cio</a></span></li>

                    <li><span><a href="/Empresa/SelectEmpresa">Tarefas Contabilidade</a></span></li>

                    <li><a href='#'><span>Clientes</span></a>

                        <ul>

                            <li><span><a href="/Empresa/ListarEmpresas">Listar clientes</a></span></li>

                            <li><span><a href="/Salao/ListaSalaoByEmpresa">Listar sal&#245;es</a></span></li>

                             <li><span><a href="/Salao/ListaEmpregadosBySalao">Gerir empregados</a></span></li>                           

                            <li><span><a href="/Empresa/Create">Novo cliente</a></span></li>

                            <li><span><a href="/Salao/Create">Novo sal&#227;o</a></span></li>   

                           </ul>

                    </li>

                     <li><a href='#'><span>Balancetes</span></a>

                        <ul>

                            <li><span><a href="/Balancete/ListaBalancetesPorSalaoMes">Listar registos</a></span></li>

                            <li><span><a href="/Balancete/UploadFile">Upload novo balancete</a></span></li>

                            <li><span><a href="/Balancete/GraficoBalancetePorSalao">Mapa Resultados/Gr&#225;fico</a></span></li>

                            <li><span><a href="/Balancete/MapaEstruturaRendimentoseGastos">Mapas Contabilidade/Gest&#227;o</a></span></li>

                            <li><span><a href="/Balancete/MapasGestao">An&#225;lise Rentabilidade</a></span></li>

                            <li><span><a href="/Balancete/alteraTaxas">Alterar taxas</a></span></li>

                        </ul>

                    </li>

                    <li><span><a href="/Home/About">Sobre</a></span></li>







                </ul>







            </div>



</nav>

i dont know if i should put the javascript inside the div or something xD

Ty

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T12:48:46+00:00Added an answer on June 8, 2026 at 12:48 pm

    You can use child selector which selects all direct child elements, Try the following:

    $(document).ready(function(){
        $(".cssmenu > ul > li").click(function () {
              $(this).siblings().removeClass("active");
              $(this).addClass("active");
        });
    })
    

    If you want to select the li tags of the inner ul tags, you can try:

    $(document).ready(function() {
        $("ul:eq(1) > li").click(function() {
           $('ul:eq(1) > li').removeClass("active");
           $(this).addClass("active");
        });
    })
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported
I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.