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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T00:15:11+00:00 2026-06-02T00:15:11+00:00

I have some recursive HTML in the following tree structure: div.item div.content input div.container

  • 0

I have some recursive HTML in the following tree structure:

div.item
 div.content
  input
  div.container
   div.item
    div.content
     input
     div.container
      div.item
       etc...

Here’s a jsfiddle with a working example: http://jsfiddle.net/HWHRZ/

I also have a objects with jQuery references to each of the .item divs.

What I want to do is, for any specific .item, select only the inputs immediately underneath, excluding those in any deeper .container or .item elements.

To make things more complicated, not every .item has an identical layout with regards to the inputs. Sometimes inputs may be in other div elements, so selecting them with a simple .find('> .content :input') won’t always work.

I have found a solution, but it’s inefficient with large trees and not at all elegant:
$(':input', $item).not($('.container :input', $item)).toggleClass('changed');

($item is a reference I keep in an object). This solution works as it should, but is way too inefficient for any sufficiently large tree structure, is the not() would have to process a lot of node.

In short: I need to select specific child nodes that are NOT within specific other child nodes.

Does anybody know of a more efficient way of doing this?

  • 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-02T00:15:13+00:00Added an answer on June 2, 2026 at 12:15 am

    I think

    $.each($($(".item")[0]).children(".changed"),function(){
    $(this).removeClass("changed")
    })
    

    should work.

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

Sidebar

Related Questions

I have some sort of recursive function, but I need to parse a string,
I have a recursive data structure that I want ASP.NET to walk in the
I have some code that has to compile for multiple platforms. The following will
I have a multi-thread C# application that uses some recursive functions in a dll.
I have a tree structure in memory that I would like to render in
I have some files that are uuencoded, and I need to decode them, using
I have some files stored at amazon. all in private mode, and since I
I have some script in my default page that redirects users to language specific
I have some Java code which performs bitwise operations on a BitSet. I have
I have some interesting problem for an hour.. In my flex project, all width

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.