text和textContent属性之间的区别 [英] Difference between text and textContent properties
问题描述
根据 HTML5规范和 DOM规范 a HTMLAnchorElement
有一个文本
和 textContent
属性。 text
属性的目的是什么?只要我可以告诉文本
只是一个只读取消者 textContent
According to the HTML5 specification and the DOM specification an HTMLAnchorElement
has a text
and a textContent
property. What is the purpose of the text
property? As far as I can tell text
is just a read-only getter for textContent
推荐答案
textContent 属性从节点接口被继承 的DOM Core规范。 文本属性是从继承的HTML5 HTMLAnchorElement界面,并指定为必须返回与textContent IDL属性相同的值。
The textContent property is "inhertied" from the Node interface of the DOM Core specification. The text property is "inherited" from the HTML5 HTMLAnchorElement interface and is specified as "must return the same value as the textContent IDL attribute".
这两个可能保留以收敛不同的浏览器行为,文本属性定义略有不同。
The two are probably retained to converge different browser behaviour, the text property for script elements is defined slightly differently.
请注意,DOM规范是任何类型的文档的一般规范(例如HTML,XML,SGML等),而HTML5则专门用于在许多方面利用和扩展DOM Core的HTML(有些人可能会说这是几个DOM规范加上HTML加上的超级集合)。
Note that the DOM specification is a general specification for any kind of document (e.g. HTML, XML, SGML, etc.) whereas HTML5 is specifically for HTML that leverages and extends the DOM Core in many respects (some might say it's a "super set" of a few DOM specs plus HTML plus …).
请注意,继承并不意味着原型继承,只是继承的一般含义。
Note that "inherited" does not mean "prototype inheritance", just the more general meaning of inherited.
这篇关于text和textContent属性之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!