Get Order of LI items in a list using JQuery...

I have a list like this:
<ul id="objectListing">
    <li><span class="itemOrder"></span>. Item One</li>
    <li><span class="itemOrder"></span>. Item Two</li>
    <li><span class="itemOrder"></span>. Item Three</li>
    <li><span class="itemOrder"></span>. Item Four</li>
</ul>

I want to, using JQuery, write a function that grabs all the items, and updates the itemOrder span with the order they appear in. So It would end up giving me this:
    1. Item One
    2. Item Two
    3. Item Three
    4. Item Four
interclubsAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
dirknibleckConnect With a Mentor Commented:
Should have been this:

$("#objectListing li").each(function(id){
     $(this).children("span").html((id+1) + ".");
});
0
 
dirknibleckCommented:
This might work:


$("#objectListing li").each(function(id){
     this.children("span").html((id+1) + ".");
});
0
All Courses

From novice to tech pro — start learning today.