jumancy
jumancy

Reputation: 1340

ordered list from bottom to top

Is it possible to make ordered list (ol) starting from the last number? For ex

5 - sasasasa

4 - sasasas

3 - sasasas

2 - sasasa

1 - sasasas

Upvotes: 1

Views: 214

Answers (2)

Shehzad Bilal
Shehzad Bilal

Reputation: 2523

Use JQuery to reverse the list, e.g.:

$(document).ready(function() {   
       var countli = $('ol > li').size();
       $("ol > li").each(function(i) {
             var attrvalue = countli - i;
             $(this).attr("value",attrvalue);
       });
    });

Upvotes: -1

Ed Guiness
Ed Guiness

Reputation: 35247

HTML 5 introduces

<ol reversed>

See an example at http://www.w3schools.com/html5/tryit.asp?filename=tryhtml5_ol

Otherwise you're stuck with specifying a value for each item

<ol>
<li value="5">Item 5</li>
<li value="4">Item 4</li>
...
</ol>

Upvotes: 7

Related Questions