Created
April 20, 2011 04:49
-
-
Save Marlena/930398 to your computer and use it in GitHub Desktop.
locating unordered list through dom in js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Node.lastChild-1 for max page number. (next link is last) | |
// Access single unordered list: [0] index | |
var unorderedList = document.getElementsByTagName('ul')[0]; | |
// Create Node list of all list items within the UL: | |
var allListItems = unorderedList.getElementsByTagName('li'); | |
// Now, we can loop through each list item using a FOR loop: | |
for (var i = 0, length = allListItems.length; i < length; i++) { | |
// Extract text node within and alert its content: | |
alert( allListItems[i].firstChild.data ); | |
} | |
from: http://net.tutsplus.com/tutorials/javascript-ajax/javascript-and-the-dom-series-lesson-1/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment