-
Website
http://blog.jeffhui.net/ -
Original page
http://blog.jeffhui.net/2009/07/brief-guide-to-javascript-part-5/ -
Subscribe
All Comments -
Community
-
Top Commenters
-
hboon
1 comment · 3 points
-
Robert Wideman
1 comment · 1 points
-
jeffhui
23 comments · 2 points
-
skoop
1 comment · 1 points
-
mardix
1 comment · 1 points
-
-
Popular Threads
var findPattern = "//a"; // This is the xpath pattern. You can use more powerful xpathes
var resultLinks = document.evaluate( findPattern, document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null );
var i=0;
while ( (res = resultLinks.snapshotItem(i) ) !=null ){
//do something to the link
i += 1;
}
For people that are interested, most javascript frameworks actually utilize XPath for selectors. XPath is a browser-supported implementation for traversing XML-trees, like HTML.