HTMLElement和Element之间有什么区别? [英] What's the difference between `HTMLElement` and `Element`?

查看:183
本文介绍了HTMLElement和Element之间有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HTMLElement Element 有什么区别?

document.createElement("div")元素实例给出真实的

document.createElement("div")实例给出了真

HTMLElement ===元素给出错误

推荐答案

HTMLElement Element ,如对DOM级别2的HTML扩展核心规格:

interface HTMLElement : Element {
           attribute DOMString       id;
           attribute DOMString       title;
           attribute DOMString       lang;
           attribute DOMString       dir;
           attribute DOMString       className;
};

Element (根据规范)指的是

Element (per specification) refers to the Element interface as it is defined in the DOM Core Level 2 specification (there is also another DOM Core specification (working draft) though).

更新:这里有很多规范,而且尚不清楚哪个浏览器使用哪个浏览器(对我来说).

Update: There are a lot of specifications out there and it is not totally clear which browsers use which one (to me).

也许其他人有更多的见识...

Maybe someone else has more insight...

但是无论如何, Element 是一个比 HTMLElement 更通用的接口,后者是从前者继承的.

But in any case, Element is a more generic interface than HTMLElement and the latter inherits from the former.

更新2:一种查看继承结构的好方法是对任何元素执行 console.dir(elementReference)(在Chrome/Safari中工作,需要Firebug才能实现)Firefox).

Update 2: A nice way to see the inheritance structure is to execute console.dir(elementReference) for any element (works in Chrome/Safari, needs Firebug for Firefox).

这篇关于HTMLElement和Element之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆