Given an ordered HTML list, is there any way given by the list item to determine its number in JavaScript, in addition to looking at its location in the list?
For example, suppose I have a list
<ol start="4" type="i">
<li>First</li>
<li>Second</li>
</ol>
which is displayed as
iv. First
v. Second
What is the best way to use JavaScript (including jQuery) which, given the LI data, find out its number?
The naive way is to look at the index of the element, add the initial value and translate it. But I wonder if there is a better way.
source
share