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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:27:45+00:00 2026-05-27T11:27:45+00:00

I have this HTML: <div id=parent1 class=article> <div class=action></div> <div id=exp1 class=expand></div> </div> <div

  • 0

I have this HTML:

<div id="parent1" class="article">
   <div class="action"></div>
   <div id="exp1" class="expand"></div>
</div>
<div id="parent2" class="article">
   <div class="action"></div>
   <div id="exp2" class="expand"></div>
</div>

and CSS:

.article:hover .action {
   z-index:1000;
}
.expand {
   display: none;
} 
action {
   background: url(../images/down.png) 0 0 no-repeat;
   z-index: -999;
}
.collapse {
   background: url(../images/up.png) 0 0 no-repeat !important;
   z-index: 1000;
}

and Javascript:

$(".article").click(function() {
   $(this).find(".action").toggleClass("collapse"); // works onclick div article
   ????????? // when press parent1 if parent2 pressed before ???????.find(".action").toggleClass("collapse");
   $("#exp2").hide(); // if previously open
   $("#exp1").toggle(300);
}

Now I need jQuery for onclick parent1 to toggleClass action in parent2 but only if prevously toggled to collapse.

  • 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-27T11:27:45+00:00Added an answer on May 27, 2026 at 11:27 am

    There are a number of ways to do it. Normally I would store a local variable that holds the state of the drop down (boolean) and just check that.

    With jQuery, since you are already using hide(), you can use:

    if ($("#exp2").is(":hidden")) {
        // Show content, set arrow to up.
        $("#exp2").removeClass("expand").addClass("collapse");
    }
    else {
        // Hide content, set arrow to down.
        $("#exp2").removeClass("collapse").addClass("expand");
    }
    

    The toggle would make more sense if you were just adding and removing a class. Here you are alternating classes. Using addClass() and removeClass() makes it very clear what you are doing.

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

Sidebar

Related Questions

I have this html: <div class=foo parent> <div class=child></div> </div> with some css: .foo{
Say I have jquery code like this: html += '<div class=index>' + item.index +
I have this HTML code: <div class='com_box'> <div class='com_box_c'> <div class='com_box_info'> <a id='quote'>quote</a> </div>
Suppose I have this html markup: <div id=wrapper> <pre class=highlight> $(function(){ // hide all
I have an html like this: <div id=container1> <div class=dragme>drag me</div> </div> <div id=container2>
This is the HTML: <div id=testBlue> <span>hello</span> <span id=testGreen class=testGreen>hello2</span> </div> If I have
I have this html: <div class=portlet-header> Company Information ... <button> some button here </button>
For example I want to extract the text in this article HTML: <div class=description>
I have this in my HTML file: <td> <div class=something>someText</div> <div class=something>otherText</div> </td> Is
I currently have the the following HTML structure: <div class=article-preview> <h1><a href=>Title</a></h1> <a class=pic-link

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.