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

  • Home
  • SEARCH
  • 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 8836681
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T09:33:06+00:00 2026-06-14T09:33:06+00:00

I have this menu: <ul id=submenu class=clearfix> <li><a href=javascript:void(0)>Vedella</a></li> <li><a href=javascript:void(0)>Minis de vedella</a></li> <li><a

  • 0

I have this menu:

           <ul id="submenu" class="clearfix">
                <li><a href="javascript:void(0)">Vedella</a></li>
                <li><a href="javascript:void(0)">Minis de vedella</a></li>
                <li><a href="javascript:void(0)">Vaca</a></li>
                <li><a href="javascript:void(0)">Poltre</a></li>
                <li><a href="javascript:void(0)">Porc Ibèric</a></li>
                <li><a href="javascript:void(0)">Pollastre</a></li>
                <li><a href="javascript:void(0)">Gall d´indi</a></li>
                <li><a href="javascript:void(0)">Bou</a></li>
            </ul>

Each of the “#submenu” li fadeIn an ul sublist and hide the other sublists.

This are the sublist:

            <ul class="sublist first_sublist">
                <li><a href="javascript:void(0)">Normal </a></li>
                <li><a href="javascript:void(0)">All i Julivert</a></li>
                <li><a href="javascript:void(0)">Formatge Roquefort</a></li>
                <li><a href="javascript:void(0)">Ceba</a></li>
            </ul>

            <ul class="sublist second_sublist">
                <li><a href="javascript:void(0)">Mini-Hamburgueses</a></li>
                <li><a href="javascript:void(0)">Surtit Mini-Hamburgueses</a></li>
            </ul>

            <ul class="sublist third_sublist">
                <li><a href="javascript:void(0)">Normal</a></li>
            </ul>

            <ul class="sublist fourth_sublist">
                <li><a href="javascript:void(0)">Poltre</a></li>
            </ul>

            <ul class="sublist fifth_sublist">
                <li><a href="javascript:void(0)">Porc ibèric de Gla</a></li>
            </ul>

and this css:

    .second_sublist, .third_sublist, .fourth_sublist, .fifth_sublist, .sixth_sublist{
        display: none;
    }

with this script:

$('#submenu li').click{
    $('#submenu li').removeClass('active');
    $(this).addClass('active');    
    $('.sublist.second_list').hide();
    $('.sublist.first_list').fadeIn();
});

The problem with the script is that it will get bigger if i have five sublists, cause i will have to make every click function per “#submenu” li.

Can someone help me to make it simple?

  • 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-14T09:33:06+00:00Added an answer on June 14, 2026 at 9:33 am

    Check this fiddle

    Use the HTML-5 data attributes to store the corresponding sublists in them..
    Approaching this way you can use a single handler to show/hide the sublists on the page.

    HTML

     <ul id="submenu" class="clearfix">
        <li><a href="javascript:void(0)" data-class="first_sublist">Vedella</a></li>
        <li><a href="javascript:void(0)" data-class="second_sublist">Minis de vedella</a></li>
        <li><a href="javascript:void(0)" data-class="third_sublist">Vaca</a></li>
        <li><a href="javascript:void(0)" data-class="fourth_sublist">Poltre</a></li>
        <li><a href="javascript:void(0)" data-class="fifth_sublist">Porc Ibèric</a></li>
        <li><a href="javascript:void(0)" data-class="first_sublist">Pollastre</a></li>
        <li><a href="javascript:void(0)">Gall d´indi</a></li>
        <li><a href="javascript:void(0)">Bou</a></li>
     </ul>
    

    Javascript

    $('#submenu li a').on('click',function() {
        var $this = $(this);
        var className = $this.data("class");
        $('#submenu li a').removeClass('active');
        $this.addClass('active');
        $('.sublist').hide();
    
        $('.'+ className).show();
    });​
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this ul menu: <ul id=superfish-1> <li class=active-trail><a href=# class=sf-depth-1 active>Inicio</a></li> <li class=trail><a
i have this html menu: <ul id='main'> <li class='active current' id='lighty'> <a href='/'>Lighty</a> <ul>
I have this html <ul id=menu> <li><input type=button id=btnMenu-1 class=btnMenu value=pitillo></li> <ul class=subMenu> <li><input
I have this menu in a partial: <ul id="submenu"> <li><a href="/mypage/profile/<%=user[0].id %>">Profile</a></li> <li><a href="/mypage/test/<%=user[0].id
I have this menu with a slide down submenu: <ul class=sf-menu> <li class=menu-item current-menu-item>
I have this toggle sliding open a menu and adding an active class to
I have this fiddle: http://jsfiddle.net/tatygrassini/tZBXe/ Horizontal dropdown menu with a 1 level deep submenu.
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 been working on this sub-menu for 8 hours now, the last little
I have this menu structure: http://jsfiddle.net/Rochefort/szL2C/ everything is ok. But i want, hover effect

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.