Created
June 1, 2017 16:19
-
-
Save matt-diehl/dd00524aa0b7e79372faa407bf8f383c to your computer and use it in GitHub Desktop.
Find all elements on a page with a specified z-index and log them to the console, sorted high to low
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
'use strict'; | |
(function() { | |
var allElements = document.querySelectorAll('*'); | |
var zIndexElements = [].map.call(allElements, function(el) { | |
var style = window.getComputedStyle(el, null); | |
var zIndex = style.getPropertyValue('z-index'); | |
return { | |
el: el, | |
zIndex: zIndex && zIndex !== 'auto' ? parseInt(zIndex) : undefined | |
} | |
}) | |
.filter(el => el.zIndex) | |
.sort((a, b) => { | |
return b.zIndex - a.zIndex; | |
}); | |
console.table(zIndexElements); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment