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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T13:23:12+00:00 2026-06-14T13:23:12+00:00

[edit] I have reworded the question and removed the example, since it seems to

  • 0

[edit] I have reworded the question and removed the example, since it seems to confuse you. Sorry for trouble.

I need to match the first descendant which match a selector.

If multiple elements match this selector but are in separates trees (i.e. if one is not the parent of another) then I want to select both of them.

The exact DOM structure is not known, so I can’t use functions like .children( ) or the > selector (because they expect the user to be sure about the actual DOM structure).

What I need actually look like the .closest( ) function, but for matching children instead of parents, and potentially multiple children at once.

  • 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-14T13:23:13+00:00Added an answer on June 14, 2026 at 1:23 pm

    Every tree starting from #B is defined by .children(); every first .foo within such a tree is .find('.foo:eq(0)'), so you should be able to use this:

    $('#B').children(':not(.foo)').andSelf().find('.foo:eq(0)');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

EDIT: I have reworded the title question slightly, and adjusted the text to respond
EDIT: reworded and simplified question to be consise... In my service layer I have
EDIT: I have changed the question as it was too localized and gained negative
EDIT I have finally figured out the problem i have been having on my
EDIT: I have fixed all but two warnings now, so thank you all for
EDIT: I have edited my post... Working on a project (c#), I have a
EDIT i have something like this in a file: imagecolor=0 arrayimagecolorcopy=0 arrayimagecolorcopy3d=0 when i
EDIT: I have realized the source of my problem. I only have count information
I won't want to have edit any working sets. I just want a way
I have an edit text which functions as a search box in my application.

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.