How do I put unordered list items into an array
Posted
by Clint
on Stack Overflow
See other posts from Stack Overflow
or by Clint
Published on 2010-05-08T10:24:51Z
Indexed on
2010/05/08
10:28 UTC
Read the original article
Hit count: 174
JavaScript
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.
© Stack Overflow or respective owner