5

Two elements in a page have the same z-index...

<div id="one" style="position: absolute; z-index: 1; top: 0px; left: 0px;"></div>
<div id="two" style="position: absolute; z-index: 1; top: 0px; left: 0px;"></div>

Div two appears in front, because it follows after div one in the source.

In jQuery is there a simple way to test whether or not an element is in front of another element?

user1031947
  • 5,764
  • 15
  • 51
  • 79
  • 1
    This might provide a solution: http://stackoverflow.com/questions/9914457/determine-visibility-real-z-index-of-html-elements – JSuar Dec 17 '12 at 02:41

1 Answers1

1

This might help: I'm getting the offset of the passed element and comparing it to element I received from elementFromPoint.

function checkClickable(id){
    var element = document.getElementById(id);
    var newElement = document.elementFromPoint(element.offsetLeft, element.offsetTop);
    if(newElement){
        if(newElement.id == id)
            return true;
    }
    return false;
}

You can use this as a base.

Akhil Sekharan
  • 12,177
  • 6
  • 37
  • 56