🤯 New: Coding Assessments Practice your skills on real-world programming challenges

jQuery Set DOM Element to Top View Z-Index

Sam Deering

jQuery function to Set any DOM Element to Top View (bring to front) using CSS Z-Index property.

jQuery.fn.mb_bringToFront= function(zIndexContext){
    var zi=1;
    var els= zIndexContext && zIndexContext!="auto" ? $(zIndexContext): $("*");
    els.not(".alwaysOnTop").each(function() {
        var cur = parseInt($(this).css('zIndex'));
        zi = cur > zi ? parseInt($(this).css('zIndex')) : zi;
    return zi;