I'm trying to write a JavaScript function that will let me refer to a numbered list item by number. (I know this code is available on the Web, but I want to write my own as a learning exercise.)

For example, if I have a list like this:

Code:
<ol>
   <li>One</li>
   <li id='L2'>Two</li>
   <li>Three</li>
</ol>
I want to be able to write a reference something like this:

Code:
Look at list item <span onload="olRef('L2')">xxx</span> and
...and have it display this:

Look at list item 2 and
To make this work I need a way of getting the number of the list item. I've seen examples that do it with the span element's value property, i.e.:

Code:
var number = document.getElementById('L2').value
but that isn't working for me. The value of .value is 0 (zero), and I don't see another property of the li object that contains its number. How do I do this?