I have a div and a UL code as follows:
<div id= "Mydiv" >
<ul id= "Myul" >
</ul>
</div>
------------------------------------------------------------
<script type= "Text/javascript" >
Get UL elements by ID
var ul = document.getElementById (' Myul ');
Here I loop 5 of
for (var i = 0; i < 5; i++) {
; //Add Li
var li = document.createelement ("Li");
var a = document.createelement ("a");
Ul.appendchild (LI);
Li.setattribute ("id", i+1);
Li.setattribute ("onclick", "getId (This)");
Li.appendchild (a);
a.innerhtml = "data (can be used to cycle out the desired data)";
function GetId (obj) {
Get the ID of the click Li element
var id = obj.id;
Alert ("The element ID you clicked on is" +id);
}
</script>
---------------------------------------------------
The last to obtain is
<div id= "mydiv" class= "Monitor" >
<ul id= "Myul" >
<li id= "1" >
<a> data (can be used to cycle out the desired data) </a>
</li>
<li id= "2" >
<a> data (can be used to cycle out the desired data) </a>
</li>
<li id= "3" >
<a> data (can be used to cycle out the desired data) </a>
</li>
<li id= "4" >
<a> data (can be used to cycle out the desired data) </a>
</li>
<li id= "5" >
<a> data (can be used to cycle out the desired data) </a>
</li>
</ul>
</div>
JavaScript dynamically generated list (gets the ID of the click List)