Created
February 24, 2012 08:50
-
-
Save draeton/1899546 to your computer and use it in GitHub Desktop.
$.maxZ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// inspired by: | |
// http://snipplr.com/view.php?codeview&id=15214 | |
(function ($) { | |
$.maxZ = function () { | |
var $all = $("body > *"); | |
return Math.max.apply(Math, $.map($all, function (el) { | |
var $el = $(el); | |
var z = 0; | |
if ($el.css("position") !== "static") { | |
z = parseInt($el.css("z-index"), 10) || 1; | |
} | |
return z; | |
})); | |
}; | |
}(jQuery)); | |
// console.log($.maxZ()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment