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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T06:04:17+00:00 2026-06-19T06:04:17+00:00

I have a page that uses jQuery tabs. Each tab contains one or more

  • 0

I have a page that uses jQuery tabs. Each tab contains one or more jQuery accordions, which are generated dynamically, in addition to other stuff. Example:

<div id="tab1" class="tab">
    <div>
        Some stuff
    </div>
    <div class="accordion">
        I am an accordion
    </div>
</div>
<div id="tab2" class="tab">
    <div class="accordion">
        I am also an accordion
    </div>
    More stuff
    <div class="accordion">
        I am also an accordion
    </div>
</div>

I would like the first accordion in each tab to remain open, while the others (if there are any) are collapsed. I have tried:

$('.tab .accordion:first')

which only selects the first accordion on the page (obviously). I also tried:

$('.tab .accordion:first-child')

This selects the first accordion in tab2 but it doesn’t select the one in tab1 because there’s some stuff above it. I’ve also tried:

$('.tab > .accordion').filter(':first-child')
$('.tab').children('.accordion:first-child')

Along with about every combination of selectors I can think of. At this point my brain is fried. Before you point me to a duplicate question, none of these are asking the same question exactly:

JQuery Tab each Selected tab first text box focus

jquery select first child with class of a parent with class

jQuery selector for each first element on every parent

jQuery Selecting the first child with a specific attribute

The difference in my case is I have very little control over what content shows up in these tabs.

  • 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-19T06:04:18+00:00Added an answer on June 19, 2026 at 6:04 am

    I’d suggest:

    $('.tab').find('.accordion:first');
    

    JS Fiddle proof-of-concept.

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

Sidebar

Related Questions

I have a one page website that uses jQuery.ScrollTo with a layout like this:
I have a page that uses jQuery tabs to tabify a set of HTML
I have a page that uses JQuery UI Tabs and some other bits and
I have a coldfusion page that uses JQuery UI TAB to load another coldfufion
I have a page that uses jQuery UI Tabs that has both static and
I have a page that uses jQuery with a small glitch. I managed to
I have a web page that uses jquery ajax to grab the table markup
I have a page going here that uses jQuery: http://treethink.com/services What I am trying
I have a page that uses JQuery UI; in particular the Sortable interaction. The
I have a page that uses the jquery function: $(document).ready(function() { and I have

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.