Andrei Maieras Andrei Maieras - 4 months ago 19
HTML Question

Get nested element by tag->id->element with javascript

document.getElement(div#menuArea).getElements(a)


I want to get all the a elements from a
div
with id
"menuArea"
. I think above syntax is wrong. Can anyone point me in the right direction?

Answer

Try this

document.getElementById('menuArea').getElementsByTagName('a')

Or for IE8+

document.querySelectorAll('#menuArea a')
Comments