document.getElement(div#menuArea).getElements(a)
我想从 ID 为 "menuArea"
的 div
中获取所有 a 元素。我认为上面的语法是错误的。谁能指出我正确的方向?
最佳答案
试试这个
document.getElementById('menuArea').getElementsByTagName('a')
或者对于 IE8+
document.querySelectorAll('#menuArea a')
关于javascript - 通过 tag->id->element 使用 javascript 获取嵌套元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28736829/