Last active
November 30, 2016 11:09
-
-
Save jcdarwin/f0d1978c0f885235b914 to your computer and use it in GitHub Desktop.
View the z-index of elements on a page
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
// 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