Questions tagged «dom-traversal»

10
querySelectorAll和getElementsBy *方法返回什么?
做getElementsByClassName(以及类似的功能,例如getElementsByTagName和querySelectorAll)与getElementById,还是他们返回元素的数组? 我问的原因是因为我试图使用更改所有元素的样式getElementsByClassName。见下文。 //doesn't work document.getElementsByClassName('myElement').style.size = '100px'; //works document.getElementById('myIdElement').style.size = '100px';
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.