I'm trying to figure out what I'm missing with the script below. My goal is to have an ordered list (per assignment requirements), where a pop up window with text comes up when any of the list items are clicked. Each list item would lead to different text.
I know there may be more efficient ways to do this, which are out of the scope of my understanding at this point, so I'm trying to do the following [non-working] work-around below.
Example: When the user clicks the "One" list item, a pop up window should appear with the text inside it saying "Item 1", but I get "undefined" as a result. Any tips?
My test HTML:
<ol id="javaList" onclick="popUp()">
<li value="Item 1">One</li>
<li value="Item 2">Two</li>
<li value="Item 3">Three</li>
</ol>
The JavaScript:
<script>
window.popUp = function() {
var myWindow = window.open("", "", "width=400, height=200");
var ls = document.getElementsByTagName("li");
myWindow.document.write(ls.value);
}
</script>