Created
April 19, 2024 10:27
-
-
Save danew/3113a715102b7f26a3bce1f2bad86cca to your computer and use it in GitHub Desktop.
Print all elements and their z-index to console in descending order
This file contains hidden or 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
(() => { | |
const elements = Array.from(document.querySelectorAll('*')); | |
const zIndexedElements = elements.map(element => ({ | |
element, | |
zIndex: window.getComputedStyle(element).zIndex | |
})) | |
.filter(item => item.zIndex !== 'auto') | |
.sort((a, b) => b.zIndex - a.zIndex); | |
zIndexedElements.forEach(({ element, zIndex }) => { | |
console.log(zIndex, element); | |
}) | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment