开发者

What is the relationship between domNode and htmlelement?

I am confused about the two terms. What is the difference in browser-side javascript programming? I use dojo as framework. And there is only the concept of domNode. But browser debugge开发者_JAVA技巧r always told me something as htmlelement. Are they just the same thing with different names, or with some subtle differences?

Thanks.


Practically speaking, they are the same, except an htmlelement wouldn't necessarily have to already be inserted into the dom.


The browser represents all of the parts of your HTML as part of a tree called the DOM (Document Object Model.) Everything in the DOM is a Node. Some nodes are also Elements, but not all.

In this fragment of HTML:

<p>I <em>like</em> HTML</p>

There are two Elements, the <p> and the <em> tags. But there are 5 Nodes: The two elements, and three Text Nodes, containing the strings "I ", "like", and " HTML".

The DOM is supposed to be generic, supporting XML as well as HTML. However, there are some extended APIs which make HTML more convenient. HTMLElement is the Element subtype that provides those extensions, so that is what you see most often.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜