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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:19:42+00:00 2026-06-14T05:19:42+00:00

i´m trying to make a menu that if you click on one item it

  • 0

i´m trying to make a menu that if you click on one item it displays divs of the specific class and hide all the others.

This is what I have made:

    <ul class="pdf_documents clearfix">
        <li class="tab-periodicos active"><a href="javascript:void(0)">Informes periódicos</a></li>
        <li class="tab-folletos"><a href="javascript:void(0)">Folleto/DFI</a></li>
        <li class="tab-fichas"><a href="javascript:void(0)">Fichas</a></li>
        <li class="tab-accionistas"><a href="javascript:void(0)">Junta de accionistas</a></li>
        <li class="tab-otros"><a href="javascript:void(0)">Otros</a></li>
    </ul>

    <div class="pdf_box clearfix">
        <div class="pdf_file periodicos">
            <img src="images/pdf.png" alt="pdf" width="70" height="70">
            <p>Último informe anual</p>
        </div>
        <div class="pdf_file periodicos">
            <img src="images/pdf.png" alt="pdf" width="70" height="70">
            <p>Último informe semestral</p>
        </div>
        <div class="pdf_file periodicos">
            <img src="images/pdf.png" alt="pdf" width="70" height="70">
            <p>Último informe trimestral</p>
        </div>
        <div class="pdf_file periodicos">
            <img src="images/pdf.png" alt="pdf" width="70" height="70">
            <p>Penúltimo informe trimestral</p>
        </div>
        <div class="pdf_file folletos">
            <img src="images/pdf.png" alt="pdf" width="70" height="70">
            <p>Folleto simplificado</p>
        </div>
        <div class="pdf_file folletos">
            <img src="images/pdf.png" alt="pdf" width="70" height="70">
            <p>Folleto completo</p>
        </div>
        <div class="pdf_file fichas">
            <img src="images/pdf.png" alt="pdf" width="70" height="70">
            <p>Ficha mensual</p>
        </div>
        <div class="pdf_file fichas">
            <img src="images/pdf.png" alt="pdf" width="70" height="70">
            <p>Ficha comercial</p>
        </div>
        <div class="pdf_file accionistas">
            <img src="images/pdf.png" alt="pdf" width="70" height="70">
            <p>Convocatoria</p>
        </div>
        <div class="pdf_file accionistas">
            <img src="images/pdf.png" alt="pdf" width="70" height="70">
            <p>Propuestas</p>
        </div>
        <div class="pdf_file accionistas">
            <img src="images/pdf.png" alt="pdf" width="70" height="70">
            <p>Informe técnico</p>
        </div>
        <div class="pdf_file otros">
            <img src="images/pdf.png" alt="pdf" width="70" height="70">
            <p>Otros</p>
        </div>
    </div>

CSS:

.pdf_box .folletos{ 
    display:none; 
}

And this is the script that I have written:

    $('.tab-periodicos').click(function(e){
        $('.pdf_documents li').removeClass('active');
        $(this).addClass('active');    
        $('.pdf_box .folletos').hide();
        $('.pdf_box .periodicos').fadeIn();
    });
    $('.tab-folletos').click(function(e){
        $('.pdf_documents li').removeClass('active');
        $(this).addClass('active');
        $('.pdf_box .periodicos').hide();
        $('.pdf_box .folletos').fadeIn();
    });

The problem with the script is that I think it should be an easy way just to point out to fadeIn one div class and hide the other items, instead of writing every div class to hide which make the script pretty big.

Any ideas on how to simplify it?

  • 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-14T05:19:43+00:00Added an answer on June 14, 2026 at 5:19 am

    Get your the divs according to your li class

    $('.pdf_documents li').click(function(){
        $('li.active').removeClass('active'); // remove active class
        var c = $(this).attr('class').split('-')[1]; // used to get correct divs
        var $ele = $('.pdf_box div.'+c); // the divs you want
        $('.pdf_box div').not($ele).hide(); // hide all other divs
        $ele.show(); // show your divs
        $(this).addClass('active'); // add active to current li
    });​
    

    http://jsfiddle.net/TWAK2/

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

Sidebar

Related Questions

I am trying to make a jquery menu that when I click on one
I am trying to make a menu that works like the one on this
I am trying to make a menu that works like the one on this
I am trying to make a dropdown menu that when you click dropdown a
I am trying to make a Xml Image Menu that on button click goes
I'm trying to make a simple accordion style menu using divs: <div class=subdomainLevel> Subdomain
I'm trying to make it so that my dropdown menu shows when you click
I'm trying to make dynamic menu using xml data, I'm creating that menu using
I'm trying to make a simple app that sits on the Mac OSX menu
I'm trying to make a context menu for a control that is linked to

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.