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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T04:12:21+00:00 2026-05-21T04:12:21+00:00

if i have 2 divs (z index is not assigned), one layered over the

  • 0

if i have 2 divs (z index is not assigned), one layered over the over, can i use the reference to the top div to find which div is below it?

as far as the DOM structure goes, these two divs would be siblings. but visually they are stacked on one another.

here’s an example:

<body>
<div id="box1" style="background:#e0e0e0;height:100px;width:100px;"></div>
<div id="box2" style="background:#000000;height:100px;width:100px;margin-top:-50px;"></div>
</body>

which results in this:
enter image description here

so i’m trying to figure out, when having the black div, box2, a way to return box1 in jquery (using selectors), because box1 is beneath box2, using jquery.

  • 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-21T04:12:21+00:00Added an answer on May 21, 2026 at 4:12 am

    Check if box1 is sharing the same position as a certain spot on the page.


    And only because I’m a little bored, I made this awesome-er

    http://jsfiddle.net/hunter/PBAb6/

    function GetAllElementsAt(x, y) {
        var $elements = $("body *").map(function() {
            var $this = $(this);
            var offset = $this.offset();
            var l = offset.left;
            var t = offset.top;
            var h = $this.height();
            var w = $this.width();
    
            var maxx = l + w;
            var maxy = t + h;
    
            return (y <= maxy && y >= t) && (x <= maxx && x >= l) ? $this : null;
        });
    
        return $elements;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a list which have divs inside it.. Now when i use nested
I have two divs floated next to one another: <div id=parent> <div id=child_1 style=float:left>
I have a DIV which loads other DIVs on button clicks but the default
I have two divs float:left. I z-index the first div to be above, but
I have 2 divs in an outer div. The outer div has a top
I have got three pages/divs sliding through (on one index page) using javascript/jquery, and
I have a bunch of divs that the user can create and which represent
I have a webpage with a div which contains several other divs WITHOUT an
Have three divs in a container that I want to float over a large
I have three divs, within a content div. Container width 70%. Within that I

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.