From 5e89481ab851e28380f10675f6620345150c3007 Mon Sep 17 00:00:00 2001 From: Scott González Date: Wed, 5 Aug 2009 13:30:55 +0000 Subject: Added zIndex method. Fixes #4709 - Add zIndex setter/getter method. --- ui/ui.core.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'ui') 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 + //
+ if (elem.style.zIndex !== '' && elem.style.zIndex !== 0) { + return +elem.style.zIndex; + } + elem = elem.parentNode; + } + + return 0; } }); -- cgit v1.2.3