jquery: addClass 1,2,3 etc. auto to a list

Posted by Svensson on Stack Overflow See other posts from Stack Overflow or by Svensson
Published on 2010-04-15T14:16:45Z Indexed on 2010/04/15 14:23 UTC
Read the original article Hit count: 225

Filed under:
|
|

Hello,

is it possible, to add auto numeric classes to a list by using jquery?

html:

<ul id="list">
 <li>Element 1</li>
 <li>Element 2</li>
 <li>Element 3</li>
 <li>Element 4</li>
 <li>Element 5</li>
</ul>

i want to get something like this:

<ul id="list">
 <li class="1">Element 1</li>
 <li class="2">Element 2</li>
 <li class="3">Element 3</li>
 <li class="4">Element 4</li>
 <li class="5">Element 5</li>
</ul>

hope there is a solution available :-)

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about list