i want to know the id names f开发者_JS百科rom links inside #nav div, i try to find what id have , but i dont find nothing about this.
You can use XPath expression to get set containing all interesting nodes.
document.evaluate("//div[@id='nav']/a", document, null, XPathResult.UNORDERED_NODE_ITERATOR_TYPE, null)
Code above will return set containing all a elements that are children of div element that has nav id.
Here is working example: http://jsfiddle.net/vycMP/3/
You can read more about XPath here: http://www.w3schools.com/xpath/default.asp
If you're doing this in the browser, I suggest using JQuery, then you can use a selector similar to CSS, which would make this quite easy.
$('#nav a').each(function(index) {
alert($(this).attr('id');
}
精彩评论