How can I find the highest z index in a document no matter what tags they are?
I found this code, but I tested it and it doesnβt work,
//include jQuery.js -- visit: http://jquery.com/ $(function(){ var maxZ = Math.max.apply(null,$.map($('body > *'), function(e,n){ if($(e).css('position')=='absolute') return parseInt($(e).css('z-index'))||1 ; }) ); alert(maxZ); });
Is there a better way to do this?
EDIT:
It seems that if I change the code to this,
$('body *') $('body > *') --> is for div only I guess.
source share