Description: Get the z-index for an element.
- This method does not accept any arguments.
.zIndex() method is useful for finding the z-index of an element, regardless of whether the z-index is set directly on the element or on one of its ancestors. In order to determine the z-index, this method will start at the specified element and walk up the DOM until it finds an element that is positioned and has a z-index set. If no such element is found, then the method will return a value of
This method assumes that elements with nested z-indexes would not have a z-index of
0. For example, given the following DOM the inner element will be treated as if it does not have a z-index set because it is impossible to differentiate between an explicit value of
0 and no value in Internet Explorer.
<div style="z-index: -10;"> <div style="z-index: 0;"></div> </div>