在页面中查找最大z索引的更好方法
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了在页面中查找最大z索引的更好方法相关的知识,希望对你有一定的参考价值。
I made an absolute tinny code to find the highest z-index of absolute DIVto show my shouting box and to make it appear absolutely at the top of all html elements.
I used selector of â€body > *‘ instead of ‘body *‘.
â€body > *‘ means all tags/elements which are found at first depth of
whether â€body *‘ selects all tags/elements at any depth.
It doesn’t matter what’s is the maximum/highest z-index of an absolute element
rather it matters what’s the maximum/highest z-index of the absolute elements
which are next to in first depth only to show the shouting box on top most strata.
N.B. Shouting box is appended to document.body in this case.
//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); });
以上是关于在页面中查找最大z索引的更好方法的主要内容,如果未能解决你的问题,请参考以下文章