Skip to content

Instantly share code, notes, and snippets.

@Marlena
Created April 20, 2011 04:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Marlena/930398 to your computer and use it in GitHub Desktop.
Save Marlena/930398 to your computer and use it in GitHub Desktop.
locating unordered list through dom in js
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