How do I put unordered list items into an array
- by Clint
Hi,
My code is...
How do I get the text in each list item into an array using native javascript?
<ul id="list">
<li>List Item 1</li>
<li>List Item 2</li>
<li>List Item 3</li>
<li>List Item 4</li>
</ul>
<script type="text/javascript">
var list = document.getElementById('list').childNodes.TextNode;
for(var i=0;i < list.length; i++) {
var arrValue = list[i];
alert(arrValue);
}
</script>
Many thanks.