jQuery: Add Numbers into an Ordered List
- by qwer0o
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 ols on the page; the number would increment across the ols instead of starting from 1 for each individual ol.)