HTMLCollection和DOM中的NodeList有什么区别? [英] What is the difference between a HTMLCollection and a NodeList in DOM?
本文介绍了HTMLCollection和DOM中的NodeList有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试了Google-fu,但似乎找不到该问题的好答案。请帮忙。
I tried my Google-fu but I can't seem to find any good answer to that question. Please help.
编辑:
好吧,我找到了此博客文章。因此它们来自不同的DOM级别,但是除此之外,它并没有太多说明...
Ok so I found this blog post. So they come from different DOM levels, but besides that it doesn't say much...
推荐答案
就像您说的那样,NodeList在DOM-Level-3-Core和HTMLCollection在DOM-Level-2-HTML中定义。
As you said, NodeList is defined in DOM-Level-3-Core and HTMLCollection in DOM-Level-2-HTML.
它们的接口是:
interface HTMLCollection {
readonly attribute unsigned long length;
Node item(in unsigned long index);
Node namedItem(in DOMString name);
};
interface NodeList {
Node item(in unsigned long index);
readonly attribute unsigned long length;
};
因此 NodeList 是 HTMLCollection 的后继者以更通用的形式(用于xml)。
So NodeList is a successor of HTMLCollection in a more generic form (for xml).
这篇关于HTMLCollection和DOM中的NodeList有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文