JavaScript
Article
By Sam Deering

jQuery Find Highest Z-Index on Page

By Sam Deering

jQuery code snippet find the highest z-index of absolute divs. Useful for making a new element appear absolutely at the top of all html elements.

//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);
});

Source

--ADVERTISEMENT--

Recommended
Sponsors
The most important and interesting stories in tech. Straight to your inbox, daily. Get Versioning.
Login or Create Account to Comment
Login Create Account