一些 DOM 选择方法(例如 getElementsByClassName())对于 HTMLDocument 和 HTMLElement 是通用的。
有没有通用的接口(interface)可以继承常用的选择方法? (以Node接口(interface)为例,提供了一些常用方法)。
document.getElementsByClassName("test");
element.getElementsByClassName("test");
最佳答案
两者都通过原型(prototype)链继承自 Node ,但这些特定方法似乎没有在通用接口(interface)中定义;它们独立出现在 Element
和 Document
中。
Object --> Node --> Element --> HTMLElement
\----> Document --> HTMLDocument
关于javascript - HTMLElement 和 HTMLDocument 的通用接口(interface)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10057306/