Rate this script:  I Love it  /   I Hate it

Sanitize runaway Z indexes!


Code

function sanitizeZ(elements){

        function sortByZIndex(a, b){
                return a[1] - b[1];
        }

        var tempZArray = new Array();
        for(i in elements)
                tempZArray.push([i, elements[i].style.zIndex]);

        tempZArray.sort(sortByZIndex);

        for(i in tempZArray)
                elements[ tempZArray[i][0] ].style ['zIndex'] = i;

}

 

 
Sanitize runaway Z indexes! scripts | Sanitize runaway Z indexes! snippet | Sanitize runaway Z indexes! example | Sanitize runaway Z indexes! tutorial | Sanitize runaway Z indexes! code