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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:48:11+00:00 2026-05-27T15:48:11+00:00

I have 2 main div’s. Group1 and group2. Those group divs contain other 2

  • 0

I have 2 main div’s. Group1 and group2. Those group divs contain other 2 (or more) div each. All the div’s inside the group’s have a class of .grp_item. Now grp_item is display:none and only one div in each group has a class .sel which is display:block .

How can I swap the class .sel between the groups ? Div’s inside the groups are the same between them.

Here is the structure:

<div id="group1">
    <div class="grp_item">
        <div>
        Div First
        </div>
    </div>
    <div class="grp_item sel">
        <div>
        Div second
        </div>
    </div>
</div>

<div><button id="swap">SWAP</button></div>

<div id="group2">
    <div class="grp_item sel">
        <div>
        Div First
        </div>
    </div>
    <div class="grp_item">
        <div>
        Div Two
        </div>
    </div>
</div>

So for this example, when swap button pressed, set .sel in group one to the first Div and in group2 set .sel to Div Two.

Here is the fiddle of the structure: http://jsfiddle.net/d6TFh/

Note that I can’t add any more classes in the inner div’s so I would imagine I should be first setting the classes to each and then removing them.

Is this possible using .contain() or any other way?

  • 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-27T15:48:12+00:00Added an answer on May 27, 2026 at 3:48 pm

    Based on your conversation with Ayman Safadi I think this is what you are looking for:

    var a = $('#anything .sel').attr('id')
    var b = $('#something .sel').attr('id')
    
    $('#anything .sel').removeClass('sel')
    $('#anything').find('#' + b).addClass('sel');
    
    $('#something .sel').removeClass('sel')
    $('#something').find('#' + a).addClass('sel');
    

    And the jsFiddle: http://jsfiddle.net/d6TFh/10/

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

Sidebar

Related Questions

I have four Div's one after the other inside a main div and aligned
I have a main wrapper div that is set 100% width. Inside that i
I have a main parent div that is .resizable(). One of it's child divs,
I have a div (main div) which contains several div elements(sub divs). I want
So I have a small div for the border, and three divs inside (see
I have a main div which contains two divs. One for main content and
Say I have the following DIVs: <div id=top>Page header</div> <div id=main>Main content</div> <div id=sidebar>Sidebar
I have a parent div called main. It has a bunch of child divs
I have the following html.. 1 main div having 2 child divs. I need
I want to do footer. I have main div there are all the page

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.