I was looking a bit for a solution for this, but I did not find anything surprising. Perhaps I just did not look for the right words. I found a bunch of questions about getting an index from an element, but I need the opposite.
I am trying to use javascript and jquery to get an item in an ordered list by its index in the list. For example, if I have this list:
<ol>
<li>Zero</li>
<li>One</li>
<li>Two</li>
<li>Three</li>
</ol>
I would like to be able to get the first ( Zero) at its index 0 or the second ( One) with its index 1.
So far I have tried several things:
So is there a way to do this? Thank.