Wednesday, 7 August 2013

How to characterize z-indexing for the DOM?

How to characterize z-indexing for the DOM?

I've been a bit care-less with choosing z-indexes in my CSS.
I'd like to traverse the DOM and report all the z-indexes with their
respective ID's.
For example:
id z-index
header 10
main 0
menu 20
The end result would be an object whose keys are the element id and the
value is the z-index. One might call it z_obj
// pseudo code
var z_obj = {el_id: el_zindex};
Getting the z-index for each element ( el ) should be easy using something
like filter and the code below:
// attr is attribute
data = _.filter(el.attributes, function (attr) {
return (/^z-index/).test(atttr.name);
});
But how would I traverse the DOM to get all z-indexes and store that in an
object?
I'd like to do this w/ out libraries, and using the code above if possible.
This would be a good debug tool in general.

No comments:

Post a Comment