# .zIndex()
Categories: [Methods](http://www.css88.com/jquery-ui-api/category/methods/ "View all posts in Methods") | [UI Core](http://www.css88.com/jquery-ui-api/category/ui-core/ "View all posts in UI Core")
####
* [.zIndex()](#zIndex1)
* [.zIndex()](#zIndex)
* [.zIndex( zIndex )](#zIndex2)
* [.zIndex( zIndex )](#zIndex-zIndex)
## .zIndex()Returns: [jQuery](http://api.jquery.com/Types/#jQuery)
**Description:** 為元素獲取 z-index。
* #### [.zIndex()](#zIndex)
* 該方法不接受任何參數。
`.zIndex()` 方法在查找一個元素的 z-index 時非常有用,忽略 z-index 是否是直接設置在元素上還是設置在祖先元素上。為了確定 z-index,該方法會在指定的元素上開始,且會沿著 DOM 查找,直到找到一個帶有 z-index 的已定位的元素。如果未找到這樣的元素,該方法將返回一個 `0` 值。
該方法假設帶有嵌套 z-index 的元素不帶有一個 `0` 值的 z-index。例如,給出下面的 DOM,內部元素將被當成不帶有 z-index,因為在 Internet Explorer 中無法區分一個 `0` 顯式值和無值。
```
<div style="z-index: -10;">
<div style="z-index: 0;"></div>
</div>
```
## .zIndex( zIndex )Returns: [Integer](http://api.jquery.com/Types/#Integer)
**Description:** 為元素設置 z-index。
* #### [.zIndex( zIndex )](#zIndex-zIndex)
* **zIndex**Type: [Integer](http://api.jquery.com/Types/#Integer)要設置的 z-index。
這相當于 `.css( "zIndex", zIndex )`。
- 索引
- Effects
- .addClass()
- Blind Effect
- Bounce Effect
- Clip Effect
- Color Animation
- Drop Effect
- Easings
- .effect()
- Explode Effect
- Fade Effect
- Fold Effect
- .hide()
- Highlight Effect
- Puff Effect
- Pulsate Effect
- .removeClass()
- Scale Effect
- Shake Effect
- .show()
- Size Effect
- Slide Effect
- .switchClass()
- .toggle()
- .toggleClass()
- Transfer Effect
- Effect Core
- .addClass()
- Color Animation
- .effect()
- .hide()
- .removeClass()
- .show()
- .switchClass()
- .toggle()
- .toggleClass()
- Interactions
- Draggable Widget
- Droppable Widget
- Mouse Interaction
- Resizable Widget
- Resizable Widget
- Selectable Widget
- Sortable Widget
- Method Overrides
- .addClass()
- .focus()
- .hide()
- .position()
- .removeClass()
- .show()
- .toggle()
- .toggleClass()
- Methods
- .disableSelection()
- .effect()
- .enableSelection()
- .focus()
- .hide()
- .position()
- .removeUniqueId()
- .scrollParent()
- .show()
- .toggle()
- .uniqueId()
- .zIndex()
- Selectors
- :data() Selector
- :focusable Selector
- :tabbable Selector
- Theming
- CSS 框架(CSS Framework)
- Icons
- Stacking Elements
- UI Core
- :data() Selector
- .disableSelection()
- .enableSelection()
- .focus()
- :focusable Selector
- .removeUniqueId()
- .scrollParent()
- :tabbable Selector
- .uniqueId()
- .zIndex()
- Utilities
- Easings
- Widget Factory
- Widget Plugin Bridge
- Mouse Interaction
- .position()
- Widgets
- Accordion Widget
- Autocomplete Widget
- Button Widget
- Datepicker Widget
- Dialog Widget
- Menu Widget
- Progressbar Widget
- Slider Widget
- Spinner Widget
- Tabs Widget
- Tooltip Widget