javascript document.getElements() 支持
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4363036/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
document.getElements() support
提问by Ralph D
How well supported is the document.getElements() function. Additionally, is there a javascript reference page that has detailed browser support information somewhere. I usually use the mozilla docs, but I was wondering if there is something better.
document.getElements() 函数的支持程度如何。此外,是否有一个 javascript 参考页面在某处提供了详细的浏览器支持信息。我通常使用 mozilla 文档,但我想知道是否有更好的东西。
I actually can't find any documentation on document.getElements() but when I do things like:
我实际上找不到有关 document.getElements() 的任何文档,但是当我执行以下操作时:
document.getElements("div a");
document.getElements("div a");
It works great in chrome, ff, safari, ie8 and ie6-9 via IETester. I think IETester may use the same javascript engine for all browsers though (not sure about that).
它通过 IETester 在 chrome、ff、safari、ie8 和 ie6-9 中运行良好。我认为 IETester 可能会为所有浏览器使用相同的 javascript 引擎(不确定)。
回答by Zevan
There is no such thing as document.getElements... I'll bet your coding in Jsfiddle and don't realize that the mootools lib is included ;)
没有 document.getElements 之类的东西......我打赌你在 Jsfiddle 中编码并且没有意识到包含 mootools 库;)
Have a look: http://jsfiddle.net/Zevan/pRKzy/
回答by Nick Craver
quirksmode.orgis a pretty good resource for things like this (though not fully updated on IE9, as it's a moving target at the moment).
quirksmode.org是此类事情的一个很好的资源(虽然在 IE9 上没有完全更新,因为它目前是一个移动的目标)。
Note: they don't have an entry for document.getElements()specifically (are you sure you're getting this name right?), but in general it's a pretty complete reference, here's an example- check out .querySelectorAll()(which does what you describe...).
注意:他们没有document.getElements()专门的条目(你确定你的名字正确吗?),但总的来说,这是一个非常完整的参考,这是一个例子- 看看.querySelectorAll()(它符合你的描述......) .
回答by Eugen Konkov
Probably you are looking for querySelecterAllfunction:
可能您正在寻找querySelecterAll功能:
elementList = parentNode.querySelectorAll(selectors);
This is most handy and much usable function.
这是最方便和最有用的功能。
To check how your requested feature is supported among browsers you can use "Can I Use" site:
要检查浏览器如何支持您请求的功能,您可以使用“我可以使用”站点:
https://caniuse.com/#search=querySelectorAll
On this site you can check not only functions but HTML attributes and CSS capabilities too
在此站点上,您不仅可以查看功能,还可以查看 HTML 属性和 CSS 功能

