.zIndex()

.zIndex()

.zIndex()Returns: Integer

Description: Get the z-index for an element.

  • .zIndex()

    • This method does not accept any arguments.

The .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 0.

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>

.zIndex( zIndex )Returns: jQuery

Description: Set the z-index for an element.

This is equivalent to .css( "zIndex", zIndex ).

© The jQuery Foundation and other contributors
Licensed under the MIT License.
https://api.jqueryui.com/zIndex

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部