tags:

views:

22

answers:

2

i want to know the id names from links inside #nav div, i try to find what id have , but i dont find nothing about this.

A: 

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

cps7
A: 

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');
}
Spudley