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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T00:45:43+00:00 2026-06-11T00:45:43+00:00

Need a bit help. Still a beginner at jQuery… I have a product package

  • 0

Need a bit help. Still a beginner at jQuery…
I have a product package comparison table. First column contains the functions. If I click on a function it opens and shows the description of the function in accordion style, and makes the function name bold (adds class ‘active’) as the active accordion header.
By default all the accordions are closed. I want only 1 accordion to be open at the same time so if the visitor clicks on another the previous one automatically closes. I made this work. The problem comes up when I click the Accordion head again to close it because it will open instantly again, however it removes the active class.
How can I close the 1 accordion which is opened without making it open again instantly (thought about an if statement, but not sure how to make it work…)?

Here is the html:

<tr>
    <td><div class="accordion"><h4><a href="javascript:(void)">Accordion head</a></h4><div class="module-desc">Service description</div></div></td>
    <td><img src="assets_wm/images/someimg.png" alt="pipa" /></td>
    <td><img src="assets_wm/images/simeimg.png" alt="pipa" /></td>
    <td><img src="assets_wm/images/someimg.png" alt="pipa" /></td>
</tr>
<tr>
    <td><div class="accordion"><h4><a href="javascript:(void)">Accordion head</a></h4><div class="module-desc">Service description</div></div></td>
    <td><img src="assets_wm/images/someimg.png" alt="pipa" /></td>
    <td><img src="assets_wm/images/someimg.png" alt="pipa" /></td>
    <td><img src="assets_wm/images/someimg.png" alt="pipa" /></td>
</tr>
<tr>
    <td><div class="accordion"><h4><a href="javascript:(void)">Accordion head</a></h4><div class="module-desc">Service description</div></div></td>
    <td><img src="assets_wm/images/someimg.png" alt="pipa" /></td>
    <td><img src="assets_wm/images/someimg.png" alt="pipa" /></td>
    <td><img src="assets_wm/images/someimg.png" alt="pipa" /></td>
</tr>

Here is the jQuery code:

$(document).ready(function(){
$(".module-desc").hide();
$(".accordion h4").click(function(){ 
        $(".accordion").find(".module-desc").hide("fast"); 
        var thisBlock = $(this).parent().index('.accordion');
        $(".accordion").find(".active").not($(this)).removeClass("active");
        $(this).toggleClass("active").next().slideToggle("fast");
        $(this).parent().toggleClass("activeToggle").siblings()
.removeClass("activeToggle").children(".module-desc").hide("fast");
        return false;       

    });
});

JsFiddle link:
http://jsfiddle.net/5QT6A/
Only service description should be hidden. The images need to stay visible even after the accordion closes.

  • 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-11T00:45:45+00:00Added an answer on June 11, 2026 at 12:45 am

    Just realised there’s a simpler way than my previous answer. First toggle the clicked items active class and do a slide toggle on the next item (the content). Then for everything else that is not the clicked item, remove the active class and slide the next item (the content) up.

    $(document).ready(function(){
        $(".module-desc").hide();
        $(".accordion h4").click(function(){
            $(this).toggleClass("active").next().slideToggle("fast");
            $(".accordion h4").not($(this)).removeClass("active").next().slideUp("fast");
            return false;
        });
    });
    

    Example: jsfiddle

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

Sidebar

Related Questions

I need a bit of help with some Ruby array jujitsu. I have the
still trying to figure out jQuery and I need some help with a sidebar
EDIT: Ok I am a bit closer but still need help... http://pastebin.com/9vdhGT2V Disclaimer: This
I'm still learning Jquery and a bit confused with the task I have on
I need a bit of help from any of the coders out there..... Currently,
I need a bit of help; I'm helping a friend port a Delphi app
I don't know MySQL very well so I need a bit of help with
I need a wee bit of help with css formatting on my website. Please
I'm a SQL noob, and I need a little bit of help understanding the
I need some help understanding this bit of code pre { white-space: pre; white-space:

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.