Latest web development tutorials

jQuery UI API - .zIndex ()

category

Method (in Methods) | the UI core (UI Core)

.zIndex () Usage

Description: Get the element z-index.

Returns: the jQuery

.zIndex()

This method does not accept any parameters.

.zIndex() method is very useful when searching for an element z-index, ignoring whether the z-index is set directly on the element or elements provided on the ancestor. To determine the z-index, which will begin on the specified elements, and looks along the DOM, until it finds an element with a z-index has been targeted. If no such element is found, the method returns a 0 value.

This method assumes that z-index with nested elements without a 0 value of z-index. For example, given the following DOM, will be treated as internal element without z-index, because they can not distinguish one in Internet Explorer 0 explicit value and no value.

<Div style = "z-index: -10;">
  <Div style = "z-index: 0;"> </ div>
</ Div>

.zIndex (zIndex) Usage

Description: Set the z-index for the element.

Returns: Integer

.zIndex( zIndex )

参数 类型 描述
zIndex Integer 要设置的 z-index。

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