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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T01:57:46+00:00 2026-05-21T01:57:46+00:00

I have several DIVs on a page,only one is open and others are closed,

  • 0

I have several DIVs on a page,only one is open and others are closed, I want that on click of a closed DIV it gets opened and, the previously opened DIV is closed, if any. It is all working fine, but the problem is: there is a lot of flicker seen in the scrollbar as well as the animating DIVs.

How can I remove this flicker ?

Please suggest ?

$(function () {
            $(".OpenedIdea").find("img").first().click(CollapseFunction);
            $(".ClosedIdea").find("img").first().click(ExpandFunction);
        });

        function CollapseFunction() {
            $(this).attr("src", srcE);
            $(this).unbind("click");
            $(this).click(ExpandFunction);

            $(this).parents("div.OpenedIdea").first().removeClass("OpenedIdea").
addClass("ClosedIdea");

            var ideaDiv = $(this).parents("div").first().next();
            ideaDiv.toggle("blind", 300, function () {
                $("html,body").animate({ scrollTop: ideaDiv.offset().top - 100 },
                { duration: 'slow', easing: 'swing' });
            });

        }

        function ExpandFunction() {
            $(this).attr("src", srcC);
            $(this).unbind("click");
            $(this).click(CollapseFunction);

            $(".OpenedIdea").find("img").first().click();
            $(this).parents("div.ClosedIdea").first().removeClass("ClosedIdea").
addClass("OpenedIdea");

            var ideaDiv = $(this).parents("div").first().next();
            ideaDiv.toggle("blind", 300, function () {
                $("html,body").animate({ scrollTop: ideaDiv.offset().top - 100 },
                { duration: 'slow', easing: 'swing' });
            });
  • 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-21T01:57:46+00:00Added an answer on May 21, 2026 at 1:57 am

    It’s a little hard to know without an example or your HTML, but it seems like what you want is the jQuery UI accordion. If you insist on doing it yourself, I would suggest something following this approach using a single click handler.

    <div>
       <span class="opener opened">&nbsp;</a>
       <div class="opened idea">
       </div>
       <span class="opener">&nbsp;</a>
       <div class="idea">
       </div>
    </div>
    
    <script type="text/javascript">
       $(function() {
             // hide all but the opened div
             $('div.idea').hide().filter('.open').show();
    
             // handle open
             $('.opener').click( function() {
                   var $opener = $(this);
                   var $next = $(this).next('div.idea');
    
                   // if opener for a closed div is clicked
                   if (!$next.hasClass('opened')) {
                      // close the open div
                      $('div.opened').toggle('blind',300,function() {
                           // change it's opener to be "closed" and mark the div as closed
                           $('span.opened').removeClass('opened');
                           $(this).removeClass('opened');
    
                           // open the div following the clicked opener 
                           $next.addClass('opened').toggle('blind',300, function() {
                                // mark it's opener as "opened"
                                $(this).prev('a.opener').addClass('opened');
                           });
                      });
                   }
             });
        });
    </script>
    

    Then use a bit of CSS to handle the visual styling of the opener/closer

    a.opener
    {
        background: url('images/closed.png') no-repeat;
        width: 20px; // or the width of your image
        height: 20px; // or the height of your image
    }
    
    a.opened
    {
        background: url('images/opened.png') no-repeat;
    }  
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have several divs with one class on a page. <div class=main/> <div class=main/>
I have a page with several .desc divs. I want to add some html
I have several divs that share a common class. If one of these divs
I have a page that generates json data from several fields and I want
I'm at a standstill with this code. I have one page with several divs,
I have several forms inside DIVS on my page. I have one form which
I have a page I am working with that has several hidden DIVs that
I have several divs on a page that all have the same width but
I have several divs on a page. Each div has a heading which I
I have several DIVs on my page that I would like to be able

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.