Andrei Maieras Andrei Maieras - 1 year ago 61
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 Source

Try this

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

Or for IE8+

document.querySelectorAll('#menuArea a')