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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T08:58:20+00:00 2026-05-15T08:58:20+00:00

lets say i have a tree of the following structure: <div>node level1 <div>node level2

  • 0

lets say i have a tree of the following structure:

<div>node level1
     <div>node level2
          <div>node level3...etc

Is there a way in jQuery, that if div level1 is clicked, only divs of level2 respond?

meaning:

$('div').click(function(){
$('div').children(first div child).css('color','red');
})

thanks for any input!

::EDIT::
hey everyone, thanks for your patience and input. i stubbornly went about solving this problem, and it worked out. i just had to find a way to crack inside the structure of my tree and it all became very clear.

i basically wanted to find a way to make a superfish-esque tree collapse/expand without being stuck inside the “li ul li” examples i had been seeing as I felt they were a bit opaque.

this fiddle has my solution. note: i am assuming that if something has 0 children it will most likely be a link to be followed. i am sure with the structure I have set out, and your able minds will be able to solve this last step.

thanks for all help and i look forward to any feedback.
final note: this can be easily soft coded to agree with any tree structure size. a while loop that acknowledges children or node clicked, that allows for concatenation and calls an eval function will be able to drill all the way down in the sub-nodes and make sure they are all hidden before the main node is also hidden.

just a side thought.

  • 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-15T08:58:20+00:00Added an answer on May 15, 2026 at 8:58 am

    You can do it like this:

    $('div').click(function(){
      $(this).children('div').css('color','red');
    });
    

    Instead of selecting all <div> elements again, use this and do .children() from there to get the immediate child <div> elements. Here’s a quick example, note for this example, the <div>s need a color initially, otherwise it’ll cascade down…even though it wasn’t actually applied to the level 3 elements.

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

Sidebar

Ask A Question

Stats

  • Questions 489k
  • Answers 489k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer That's really a business decision, so YMMV. I tend to… May 16, 2026 at 9:02 am
  • Editorial Team
    Editorial Team added an answer Try this: <form method="post" action="[~[*id*]~]" style="display:inline-block;background-color:#CCDFEF"> Remove the <div style="background-color:#CCDFED">… May 16, 2026 at 9:02 am
  • Editorial Team
    Editorial Team added an answer On one hand you could use Java, it's fully compatible… May 16, 2026 at 9:02 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

Lets say I have the following MySQL structure: CREATE TABLE `domains` ( `id` INT(10)
Let's say I have the following class structure: class Car; class FooCar : public
I am trying to build a Quadtree data structure(or let's just say a tree)
Let's say I have a class such as class c { // ... void
Let's say I have a large HTML file with different kinds of tags, similar
Possible Duplicate: Open file from complete path under cursor in Vim Let's say I
I wish to create a subtree from an hclust object. For example, let's say
I have a f# library with some values that I want to serialize in
My MIPS Assembly class required me to read in an expression of unknown size

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.