Greetings,
So i have this code which is doing what i sorta want but not really. Right now it just looks for all li elements of a ordered list inside a div with id content. it prepends a span tag with a number that increments from 1 yadda yadda. Ok, now the problem. When there are additional ordered lists, it should reset, right now it just continues off where the last list ends. See example below:
JS:
$(‘#content ol li’).each(function(j){
var bulletNum = j+1;
$(this).prepend(‘<span class=”bullet-‘+bulletNum+'”></span>’);
});
Outputted html:
<div id=”content”>
<ol>
<li><span class=”bullet-1″>what am</span</li>
<li><span class=”bullet-2″>i doing</span</li>
<li><span class=”bullet-3″>wrong?</span</li>
</ol>
<ol>
<li><span class=”bullet-4″>what am</span</li>
<li><span class=”bullet-5″>i doing</span</li>
<li><span class=”bullet-6″>wrong?</span</li>
</ol>
</div>
What should happen:
<div id=”content”>
<ol>
<li><span class=”bullet-1″>what am</span</li>
<li><span class=”bullet-2″>i doing</span</li>
<li><span class=”bullet-3″>wrong?</span</li>
</ol>
<ol>
<li><span class=”bullet-1″>what am</span</li>
<li><span class=”bullet-2″>i doing</span</li>
<li><span class=”bullet-3″>wrong?</span</li>
</ol>
</div>
I know this is probably easy but what am I doing wrong here?