Skip to content

Instantly share code, notes, and snippets.

@zlypher
Last active September 21, 2018 21:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zlypher/0b9b295e2ee39da4125105e88d8d7d3e to your computer and use it in GitHub Desktop.
Save zlypher/0b9b295e2ee39da4125105e88d8d7d3e to your computer and use it in GitHub Desktop.
[WF] Find elements with z-index
// 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