Skip to main content

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:
    var maxZ = Math.max.apply(null,$.map($('body > *'), function(e,n){
                return parseInt($(e).css('z-index'))||1 ;


Sam Deering has 15+ years of programming and website development experience. He was a website consultant at Console, ABC News, Flight Centre, Sapient Nitro, and the QLD Government and runs a tech blog with over 1 million views per month. Currently, Sam is the Founder of Crypto News, Australia.

Integromat Tower Ad