diff options
author | Scott González <scott.gonzalez@gmail.com> | 2009-08-05 13:30:55 +0000 |
---|---|---|
committer | Scott González <scott.gonzalez@gmail.com> | 2009-08-05 13:30:55 +0000 |
commit | 5e89481ab851e28380f10675f6620345150c3007 (patch) | |
tree | 4fd58d0e39f5c0359db341044ecf2e70159cb11f /ui | |
parent | 44d3893daaa2675aabbeabfe71719b040ff3f999 (diff) | |
download | jquery-ui-5e89481ab851e28380f10675f6620345150c3007.tar.gz jquery-ui-5e89481ab851e28380f10675f6620345150c3007.zip |
Added zIndex method. Fixes #4709 - Add zIndex setter/getter method.
Diffstat (limited to 'ui')
-rw-r--r-- | ui/ui.core.js | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/ui/ui.core.js b/ui/ui.core.js index 0e8be9abe..e166f0f06 100644 --- a/ui/ui.core.js +++ b/ui/ui.core.js @@ -184,6 +184,26 @@ $.fn.extend({ } return (/fixed/).test(this.css('position')) || !scrollParent.length ? $(document) : scrollParent; + }, + + zIndex: function(zIndex) { + if (zIndex !== undefined) { + return this.css('zIndex', zIndex); + } + + var elem = this[0]; + while (elem && elem.style) { + // IE returns 0 when zIndex is not specified + // other browsers return an empty string + // we ignore the case of nested elements with an explicit value of 0 + // <div style="z-index: -10;"><div style="z-index: 0;"></div></div> + if (elem.style.zIndex !== '' && elem.style.zIndex !== 0) { + return +elem.style.zIndex; + } + elem = elem.parentNode; + } + + return 0; } }); |