Apply z-index descending to li with jQuery

jquery, z-index

Solution

Did you know you can pass a callback argument to `.css()`?

var c = $('#list li').length;
$('#list li').css('z-index', function(i) {
    return c - i;
});

http://jsfiddle.net/mblase75/XuSX8/

Problem

I need to count the li's and then add z-index in reverse order, to look like: ``` <li style="z-index:3;"></li> <li style="z-index:2;"></li> <li style="z-index:1;"></li> ``` I do not want 0 or negatives on any z-indexes, and it needs to be in reverse order. I would like to use jQuery since I won't know how many li's will be on this list. Here is what I have so far: ``` var numIndex = $("ul.progress li").length + 1; $("ul.progress li").each( function(numIndex) { $(this).css("z-index", numIndex*-1); }); ``` Please advise if you know what I am missing.

Original source