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?
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?
- 1 You should research for answers before asking. stackoverflow.com/questions/15765639/… – NewToJS Commented Feb 26, 2015 at 7:40
2 Answers
Reset to default 14Try this
document.getElementById('menuArea').getElementsByTagName('a')
Or for IE8+
document.querySelectorAll('#menuArea a')
Or you can try jQuery:
$('#'menuArea a');
About class, try this:
var d = document.getElementById('menuArea').getElementsByTagName('a')
d.className = d.className + " otherclass";
This is pure JavaScript.