Last active
September 21, 2018 21:45
-
-
Save zlypher/0b9b295e2ee39da4125105e88d8d7d3e to your computer and use it in GitHub Desktop.
[WF] Find elements with z-index
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
// Get all css property values for a single element | |
// https://developer.mozilla.org/en-US/docs/Web/API/Window/getComputedStyle | |
// const cs = window.getComputedStyle(elem); | |
// Access single properties | |
// cs.getPropertyValue("z-index") | |
// cs["z-index"] | |
// cs.zIndex | |
// Example: Find all elements where a z-index is specified | |
// Variation A: | |
(() => { | |
const elems = Array.from(document.querySelectorAll("*")) | |
.map(elem => { | |
return { | |
elem: elem, | |
zIndex: window.getComputedStyle(elem).zIndex, | |
}; | |
}) | |
.filter(item => item.zIndex !== "auto"); | |
console.table(elems); | |
})(); | |
// Variation B | |
(() => { | |
const elems = Array.from(document.querySelectorAll("*")) | |
.filter(elem => window.getComputedStyle(elem).zIndex !== "auto") | |
.map(elem => { | |
return { | |
elem: elem, | |
zIndex: window.getComputedStyle(elem).zIndex, | |
}; | |
}); | |
console.table(elems); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment