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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T01:20:14+00:00 2026-06-01T01:20:14+00:00

Im trying to make an accordion with toggle which seems to work pretty good

  • 0

Im trying to make an accordion with toggle which seems to work pretty good now. What i would like to get some help with as a newbie to javascript is the way it is put together.

http://jsfiddle.net/z3wW4/

This isnt pretty i know…

    $(document).ready(function() {
     $('#contact').click(function() {
        $('#content2, #content3').hide(200, 'linear');
          $('#content').toggle(700, 'linear');          
    });
});

$(document).ready(function() {
     $('#services').click(function() {
        $('#content, #content3').hide(200, 'linear');
          $('#content2').toggle(700, 'linear');
    });
});

$(document).ready(function() {
     $('#about').click(function() {
        $('#content, #content2').hide(200, 'linear');
          $('#content3').toggle(700, 'linear');
    });
});
  • 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-01T01:20:15+00:00Added an answer on June 1, 2026 at 1:20 am

    I’d suggest:

     $('#menu > a').click(function() { // specifies which a elements
         var that = $(this), // caching the selectors for performance
             divs = $(this).siblings('div'),
             div = $(this).nextAll('div:first');
         divs.not(div).hide(200, 'linear'); // hides all the sibling divs *except* for the
                                            // immediately following div element
         div.toggle(700, 'linear');         // toggles the immediately-following div
    });
    

    ​
    JS Fiddle demo.

    References:

    • click().
    • nextAll().
    • not().
    • siblings().
    • toggle().
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to make some Post Application which has to show messages like the
I'm not so good at JS and I need some help I'm trying to
I've been trying to get this arrow toggle script work on my page. I
I'm trying to make an accordion-like menu with jQuery, but it refuses to cooperate:
I'm trying to make an 'accordion' effect using jQuery. I've managed to get it
I'm trying to make a JQuery accordion which will change it's style to .active{}
Repost of old question with cleaner code: Trying the make this accordion work. But
I'm trying to make an accordion like section to a page I'm working on.
I am trying to make ListBox which updates its content according to some changing
I am trying to make an accordion image gallery that works based off an

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.