Skip to content

Instantly share code, notes, and snippets.

@73nko
Created June 25, 2020 14:22
Show Gist options
  • Save 73nko/25ec114710a2b386d7bc4779461ec2ee to your computer and use it in GitHub Desktop.
Save 73nko/25ec114710a2b386d7bc4779461ec2ee to your computer and use it in GitHub Desktop.
function getHighestZ() {
let highestZ = 0;
const elements = document.querySelectorAll('*');
elements.forEach(element => {
const style = getComputedStyle(element);
const zIndex = (style.zIndex) ? parseInt(style.zIndex) : 0;
if (zIndex > highestZ) {
highestZ = zIndex;
}
});
return highestZ;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment