Skip to content

Instantly share code, notes, and snippets.

@Alsandre
Created February 7, 2025 06:32
Show Gist options
  • Save Alsandre/e370b0f369e2ac7d7c0bbaf7dffe4542 to your computer and use it in GitHub Desktop.
Save Alsandre/e370b0f369e2ac7d7c0bbaf7dffe4542 to your computer and use it in GitHub Desktop.
function getNonAutoZIndex(element) {
if (!(element instanceof Element)) {
console.warn("Invalid element provided.");
return null;
}
const zIndex = window.getComputedStyle(element).zIndex;
// Return the z-index value only if it is not 'auto'
return zIndex !== 'auto' ? parseInt(zIndex, 10) : null;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment