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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T01:52:05+00:00 2026-05-15T01:52:05+00:00

Background: I’ve created an online circuit design application where div tags are containers that

  • 0

Background: I’ve created an online circuit design application where div tags are containers that contain smaller div containers and so forth.

Question: For any particular div tag I need to quickly identify if it contains other div tags (that may in turn contain other div tags).

I’ve searched JQuery and I don’t see any built-in routine for this. Does anyone know of an algorithm that’s quicker than O(n^2)?

Seems like I have to walk the list of div tags in an outer loop (n) and have an inner loop (another n) to compare against all other div tags and do a “containment test” (position, width, height), building a list of contained div tags. That’s n-squared. Then I have to build a list of all nested div tags by concatenating contained lists. So the total would be O(n^2)+n.

There must be a better way?

  • 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-15T01:52:05+00:00Added an answer on May 15, 2026 at 1:52 am

    You can do the following checks

    $('div_selector').has('div').length > 0 // it contains divs
    

    alternatively

    $('div_selector').is(':has(div)') // returns true if it contains divs
    

    the above checks work for actual containment (nesting) in the dom (not for visual containment where the dimensions of one div are contained in the other).

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

Sidebar

Related Questions

Background to question: We are building an online web application that requires the user
Background: We're building an application that allows our customers to supply data in a
Background Given that 'most' developers are Business application developers, the features of our favorite
Background: I've inherited a web application that is intended to create on-the-fly connections between
BACKGROUND: I have an application that is freshly deployed every day -- a VM
Background: I would like to dismiss a modalView that I have presented earlier and
Background The main application where I work is based heavily on the MUMPS-esque Caché
Background I have a rails 3 app that has a model named A with
Background I am trying to build a Java program that make use of an
Background - I have a webpage that contains a bunch of buttons (think POS

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.