jQuery: Add Numbers into an Ordered List
Posted
by qwer0o
on Stack Overflow
See other posts from Stack Overflow
or by qwer0o
Published on 2010-05-23T16:33:40Z
Indexed on
2010/05/23
16:40 UTC
Read the original article
Hit count: 191
jQuery
I would like to use jQuery to make this:
<ol>
<li>item a</li>
<li>item b</li>
</ol>
<ol>
<li>item c</li>
<li>item d</li>
<li>item e</li>
</ol>
…become this:
<ol>
<li><span>1</span> item a</li>
<li><span>2</span> item b</li>
</ol>
<ol>
<li><span>1</span> item c</li>
<li><span>2</span> item d</li>
<li><span>3</span> item e</li>
</ol>
(This answer doesn't work for when there are multiple ol
s on the page; the number would increment across the ol
s instead of starting from 1 for each individual ol
.)
© Stack Overflow or respective owner