Skip to content

Instantly share code, notes, and snippets.

@jcdarwin
Last active November 30, 2016 11:09
Show Gist options
  • Save jcdarwin/f0d1978c0f885235b914 to your computer and use it in GitHub Desktop.
Save jcdarwin/f0d1978c0f885235b914 to your computer and use it in GitHub Desktop.
View the z-index of elements on a page
// To see all elements and their z-index on a page
(function(){
// To see all elements and their z-index on a page
var forEach = function (array, callback, scope) {
for (var i = 0; i < array.length; i++) {
callback.call(scope, i, array[i]);
}
};
forEach(document.querySelectorAll('*'), function (index, element) {
zindex = getComputedStyle(element).getPropertyValue("z-index")
if (zindex > 1) {
console.log(element)
console.log('zindex: ', zindex)
}
});
}())
// Alternate version
// (requires jQuery)
//$('*').each(function(i, el){
// if ($(el).css('z-index') > 1) {
// console.log(el)
// console.log($(el).css('z-index'))
// }
//});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment