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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T07:22:51+00:00 2026-06-09T07:22:51+00:00

I am trying to create a menu(no dropdown) using jquery. Please check some of

  • 0

I am trying to create a menu(no dropdown) using jquery. Please check some of my codes below.

If I click on the link of Galaxy Tab I want to display the div where the value of class attribute is galaxyTab. Similarly if I click on the link of Iphone, I want to hide the previous div(galaxyTab) and display the div where the value of class attribute is iphone. Here’s the fiddle of the following code

<div id="productMenu">
  <a href="galaxyTab" class="showproducts">Galaxy Tab</a>
  <a href="iphone" class="showproducts">Iphone</a>
  <a href="hpslate" class="showproducts">HP Slate</a>
</div>
 Unlimited... like this

<div id="article">
<div id="products" class="galaxyTab" style="">Galaxy Tab</div>
<div id="products" class="iphone" style="display:none">Iphone</div>
<div id="products" class="hpslate" style="display:none">HPslate</div>
</div>

I can achieve the above requirement by following code, but the problem is I have to fetch the menu names and other information from database and there will probably be around 15 menu items, so the following method is not feasible. Could you please show me an easy way to do this.

Thanks in advance 🙂

$('a.showproducts').click(function(){
        var a_href = '.'+ $(this).attr('href'); 
                    $('.galaxyTab').hide();
                     $('.iphone').hide();
                     $('.hpslate').hide();

                    $(a_href).show();

       return false
    });//.click function ends here
  • 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-09T07:22:53+00:00Added an answer on June 9, 2026 at 7:22 am

    There are several prebuilt solutions that will help you achieve this. Depending on how you want it to work, there is:

    Accordion:

    http://jqueryui.com/demos/accordion/

    Tabs:

    http://jqueryui.com/demos/tabs/

    Also – a note for your HTML. You shouldnt be using the same ID for multiple entries – as ID are meant to be unique.

    If you put in another class on each div, you could also write this code to manually hide the divs if you dont want to put in a big component like accordion or tabs.

    http://jsfiddle.net/Sqgbb/

    $('a.showproducts').click(function(e){
        e.preventDefault();
        var a_href = '.'+ $(this).attr('href');
        $('.products').hide();
        $(a_href).show();
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to create a dropdown javascript menu with jquery. I am using
I'm trying to create some Menu Item with Image & Label, using barry's class
I am trying to create dropdown menu for Wordpress theme and having some silly
I've been trying to create a dropdown menu using straight CSS. When you hover
OK, so. I'm trying to create a dropdown menu of sorts using fadeToggle(). http://westrock.juggernautwebsites.com/
I am trying to create a drop down menu using jQuery and CSS. Here
I am trying to create a Dynamic Dropdown menu class which contains a class
I'm trying to create a dropdown kind of menu.So on clicking on a div
I am trying to create a menu panel in jQuery, all is complete except
I have been trying to create a menu panel with jQuery that can be

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.