Skip to content

Instantly share code, notes, and snippets.

@danew
Created April 19, 2024 10:27
Show Gist options
  • Save danew/3113a715102b7f26a3bce1f2bad86cca to your computer and use it in GitHub Desktop.
Save danew/3113a715102b7f26a3bce1f2bad86cca to your computer and use it in GitHub Desktop.
Print all elements and their z-index to console in descending order
(() => {
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