Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6067617
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:37:38+00:00 2026-05-23T09:37:38+00:00

Is there a way to have a self referencing ‘list item’ in html so

  • 0

Is there a way to have a self referencing ‘list item’ in html so when I reference a number or letter in an ordered list it keeps track of changes. Therefore, when I add or remove list items it automatically change the references to update to the new ordered list number or letter.

If this type of self referencing is not possible in older html versions how about in html5?

Also is this type of referencing available in javascript or a javascript framework like jQuery?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T09:37:38+00:00Added an answer on May 23, 2026 at 9:37 am

    Given HTML like

    <ol title="Figure 1">
      <li id="poundcake">Pound Cake</li>
      <li id="spongecake">Sponge Cake</li>
    </ol>
    
    <p>The most delicious from the list above is <label for="spongecake">.</p>
    

    and then at the bottom (or onload),

    <script>(function () {
    
      // From http://stackoverflow.com/questions/5395177/ordered-list-index
      function itemIndex(listItem) {
        var index = 0;
        for (var sibling = listItem; sibling;
             sibling = sibling.previousSibling) {
          if (sibling.tagName == "LI") {
            var value = +sibling.value;
            if (value) {
              return value + index;
            }
            ++index;
          }
        }
        var start = +listItem.parentNode.start || 1;
        return start + index - 1;
      }
    
      var labels = document.getElementsByTagName("label");
      for (var i = 0, n = labels.length; i < n; ++i) {
        var label = labels[i];
        var id = label.getAttribute("for");
        if (!id) { continue; }
        var target = document.getElementById(id);
        if (!target || target.tagName !== "LI") { continue; }
        var replacementText = (target.parentNode.title || "")
            + " item " + itemIndex(target);
        label.parentNode.replaceChild(
            document.createTextNode(replacementText), label);
      }
    
    }())</script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way to have rails print out a number with commas in
i have self.some_field = [] in my class Im enquiring is there a way
Is there a way to have hanging operators when indenting with tabs in Vim?
is there a way to have the cobertura test coverage graph be shown on
Is there any way to have a label wordwrap text as needed? I have
Is there a way to have an animated loading screen for my iPhone application
Is there any way to have to tabcontrol take the size of the largest
Is there any way to have a default MessageBox.Show() caption? Let says I would
Is there a way to have a .NET assembly accessible for only authorized sources?
Is there a way to have lightbox on page load?? Say like when the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.