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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:19:49+00:00 2026-05-26T01:19:49+00:00

So I am using .toggle() to open and close a bunch of divs, but

  • 0

So I am using .toggle() to open and close a bunch of divs, but I made the first div open on page load. The problem lies where, if a user click on that div to toggle it closed, it takes two clicks, the first click seems to try to toggle it open again. How should I handle this?

$(document).ready(function(){
    $('.content_accrd').css({"height":"0px"});
    $('.content_accrd:eq(0)').css({"height":"100px"});
    $('.paneltop:eq(0)').css({"background-position":"0px -21px"})
$('.paneltop').toggle( function() {
    $(this).css({"background-position":"0px -21px"})
    .siblings('.content_accrd').animate({"height":"100px"}, 200)
}, function() {
$(this).css({"background-position":"0px 0px"})
    .siblings('.content_accrd').animate({"height":"0px"}, 200);

})
})

markup:

 <div id="panel1" class="panel">
                <h2 class="panel_title">Capad Clients</h2>
                <div class="paneltop">
                </div>
              <div class="content_accrd">
              <p>
text
              </p>
              </div>
          </div>

          <div id="panel1" class="panel">
                <div class="paneltop">
                </div>
              <div class="content_accrd">
              <p>
              text
              </p>
              </div>
          </div>


          <div id="panel1" class="panel">
                <div class="paneltop">
                </div>
              <div class="content_accrd">
              <p>
text
              </p>
              </div>
          </div>
  • 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-05-26T01:19:50+00:00Added an answer on May 26, 2026 at 1:19 am

    Example

    EDIT:

    $(document).ready(function() {
        $('.content_accrd').css({
            "height": "0px"
        });
        $('.content_accrd:eq(0)').css({
            "height": "100px"
        });
        $('.paneltop:eq(0)').css({
            "background-position": "0px -21px"
        })
        $('.paneltop').click(function() {
            if ($(this).siblings('.content_accrd').height() != 100) {
                $(this).css({
                    "background-position": "0px -21px"
                }).siblings('.content_accrd').animate({
                    "height": "100px"
                }, 200)
            } else {
                $(this).css({
                    "background-position": "0px 0px"
                }).siblings('.content_accrd').animate({
                    "height": "0px"
                }, 200);
            }
        })
    })
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using the below javascript (jQuery) to toggle open two DIVs. The DIVs
I'm using Soh Tanaka's script to toggle open and closed div content in the
I am using jQuery toggle with a link and a div. I will eventually
I'm using Jquery's toggle event to do some stuff when a user clicks a
I'm using jQuery to toggle the visibility of a <div> using the jQuery toggle
i'm using jquery toggle to show/hide a div on different links. It shows/hides them
I'm using JQuery. I'm writing this as HTML code: <li id=toggle> <a id=open class=open
Can someone please remind me how do I toggle between open projects using a
I'm new to jQuery and have setup a function to toggle a div open/closed.
I've written a cookie-based toggle show/hide menu. It remembers what was open/closed using the

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.