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 8696389
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T01:15:54+00:00 2026-06-13T01:15:54+00:00

I have problems with the active items of the menu and a submenu that

  • 0

I have problems with the active items of the menu and a submenu that toggles:
When I click over “Prensa” or “Contacto” the script adds the active well to menu item. For example “Prensa” gets the active and if I click on “Contacto”, it get’s the active removing it from “Prensa”.

The problem is when I click on “Artworks” it get’s the active class but also all the links from it’s submenu. Also if I click again over “Prensa” the submenu from “Artworks” stays open and all the links of “Artworks” still gets the active class (Also the “artworks” link itself).

Another problem is that when I click over a submenu item, it adds just a “class” without anything more, so I can’t add css to make it active.

Here it’s my markup:

        <ul id="menu" class="menu">
            <li id="artworks"><a href="#">ARTWORK</a>
                <ul class="submenu">
                    <img src="../img/submenu.png" alt="submenu" width="62" height="1" />
                    <li><a href="#" id="sweetlife">Sweet Life</a></li>
                    <li><a href="#">Pleasure</a></li>
                    <li><a href="#">Bienal de la habana</a></li>
                    <li><a href="#">Estudios de craneos</a></li>
                </ul>
            </li>
            <li id="prensa_nav"><a href="#">PRENSA</a></li>
            <li id="contacto_nav"><a href="#">CONTACTO</a></li>
        </ul>

Here it’s my js:

    // active menu item
$(function() {
    $('#menu li').click(function() {
        $('#menu li').each(function() {
            $(this).removeClass('active');
        });
        $(this).addClass('active');
    });
});


    /* Menu dropdown */
    $(document).ready(function($){

    // Add class of drop if item has sub-menu
    $('ul.submenu').closest('li').addClass('drop');

    // Left Sidebar Main Navigation
    var menu_ul = $('.menu > li.drop > ul'),
        menu_a  = $('.menu > li.drop > a');

    menu_ul.hide()    

    menu_a.click(function(e) {
        e.preventDefault();
        if(!$(this).hasClass('active')) {
            menu_a.removeClass('active');
            menu_ul.filter(':visible').slideUp('normal');
            $(this).addClass('active').next().stop(true,true).slideDown('normal');
        } else {
            $(this).removeClass('active');
            $(this).next().stop(true,true).slideUp('normal');
        }
    });

});

Can someone help me out to fix these problems?

  • 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-13T01:15:55+00:00Added an answer on June 13, 2026 at 1:15 am

    You have to style only the direct child of an active menu an not all other children.

    For the scripting, the click on a submenu is called twice: once on the child and once on the parent. First call sets the class on the child, but second call removes it instantly.
    You can prevent this ‘propagation’ of the click in jQuery.

    Example: http://jsfiddle.net/willemvb/q96FK/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have problems with dealing with widows within a multicols environment, that is, I
I have a list of tab items that have views dynamically added to them.
I have a menu with a bunch of list items. What I am trying
I have problem with my menu bar items getting stack in the wrong stat.
I have a accordion menu which is developed by using the below script $(document).ready(function(){
Original goal: I have a TreeMenu that i use to display my Menu. In
I have a menu like so: <ul class=ipro_menu> <li><a href=/>Home</a></li> <li class=active-parent><a href=/menu-item-1/>Menu Item
I have a html menu: <ul> <li><a href=# class=active>Item one</a></li> <li><a href=#>Item two</a></li> <li><a
I have a problem with the following menu: http://jsfiddle.net/H4hxA/1/ So, what the script is
We have a table that acts as a queue of items to process. 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.