Skip to content

Instantly share code, notes, and snippets.

@draeton
Created February 24, 2012 08:50
Show Gist options
  • Save draeton/1899546 to your computer and use it in GitHub Desktop.
Save draeton/1899546 to your computer and use it in GitHub Desktop.
$.maxZ
// 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