maxz
Version:
Get the maximum zIndex on a page or from a list of elements
17 lines (15 loc) • 441 B
JavaScript
module.exports = function maxz (els) {
els = els || document.body.getElementsByTagName('*')
var indices = [0]
var l = els.length
while (l--) {
var zIndex = getZzz(els[l])
if (zIndex) indices.push(zIndex)
}
return Math.max.apply(Math, indices)
}
function getZzz (el) {
if (el.style.zIndex) return Number(el.style.zIndex)
var style = el.currentStyle || window.getComputedStyle(el)
return Number(style.zIndex) || 0
}