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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T20:51:55+00:00 2026-06-12T20:51:55+00:00

If I have a nested set of DOM elements, e.g. ul > li >

  • 0

If I have a nested set of DOM elements, e.g. ul > li > ul > li and I use the selector li by itself, do either Sizzle or document.querySelectorAll define the order in which the elements will be returned?

Orderings that might be returned include “top most first”, “leaf nodes first”, or just “in document order”, but I’ve never seen anything written down to specify which.

  • 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-12T20:51:56+00:00Added an answer on June 12, 2026 at 8:51 pm

    Well, it’s quite clearly said in MDN documentation for document.querySelectorAll:

    Returns a list of the elements within the document (using depth-first
    pre-order traversal of the document’s nodes
    ) that match the specified
    group of selectors.

    W3 DOM documentation gives the same description:

    The querySelectorAll() methods on the Document, DocumentFragment, and
    Element interfaces must return a NodeList containing all of the
    matching Element nodes within the subtrees of the context node, in
    document order. […] The term ‘document order’ means a depth-first pre-order traversal of the DOM tree or subtree in question.

    In other words, given the following structure:

    <div class="a">
      <div class="a-a">
        <div class="a-a-a"></div>    
        <div class="a-a-b"></div>
      </div>
      <div class="a-b">
        <div class="a-b-a"></div>    
        <div class="a-b-b"></div>
      </div>
    </div>
    <div class="b">
      <div class="b-a">
        <div class="b-a-a"></div>    
        <div class="b-a-b"></div>
      </div>
      <div class="b-b">
        <div class="b-b-a"></div>    
        <div class="b-b-b"></div>
      </div>
    </div>
    

    … result of document.querySelectorAll('div') should be a NodeList of exactly the following order:

    ["a", "a-a", "a-a-a", "a-a-b", "a-b", "a-b-a", "a-b-b", 
     "b", "b-a", "b-a-a", "b-a-b", "b-b", "b-b-a", "b-b-b"]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table in my database which conains a nested set of items,
I have an Entity type which uses the nested set extension. When I am
Suppose I have a list of nodes which represent a nested set hierachy (examples
Is it possible to have nested set capabilities in this somewhat custom setup? Consider
I have your run of the mill nested set hierarchy type setup with the
I'd like to have the nested containers inherit that property, but when I set
I have a method with a nested foreach collection (iterate a set of objects
I have nested iframes and I would like to use onload function for the
I have a RadGrid set up to use the NeedDataSource event. I also have
I have an application that uses a nested set model class to organise my

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.