Core (ECMAScript): defines all objects, properties and methods of the scripting language
, but also include attributes, comments, text, etc.) as different nodes.
Node Structure Diagram
The above picture describes the structure diagram of DOM CORE. It is more professional. Let’s take a look at a simple one:
Let’s take a look at the DOM performance of this code in a standard browser:
The div and span elements are displayed as an element node, corresponding to the Element element in the node structure diagram
"hello world" and the space between div and span The interval is displayed as a text node, corresponding to the CharacterDate element
in the node structure diagram. When DOM CORE parses the document, it will treat all elements, attributes, text, comments, etc. as a node object ( Or objects inherited from node objects, polymorphic, upward transformation), displayed sequentially according to the text structure, and finally formed a "DOM tree"
DOM The core concept of HTML is HTMLElement , DOM HTML will treat all elements in the document (the elements here specifically refer to tags such as , excluding comments, attributes, and text) as HTMLElements. The attributes of the element are the attributes of HTMLElement.
Look at another example:
Attributes provided from the Node interface
myElement.attributes["id"].value; Obviously myElement.attributes["id"] Return an object. value is to get the value attribute of the object. The method implemented by
Element returns
myElement.getAttributes("id"); obviously at this time id is just an attribute now. This is just An operation to get properties.
In fact, the external calling interfaces of DOM Core and DOM html are not very different. For html documents, you can use DOM html to operate, and for xhtml, you can use DOM Core.
About BOM Old rules, let’s take a picture first:
BOM is closely integrated with the browser, these objects are also called is a host object, that is, an object provided by the environment.
Here we want to emphasize a strange object, the Global object, which represents a global object. Javascript does not allow independent functions, variables and constants to exist. Without additional definitions, they are all used as properties or methods of the Global object. Treat them like parseInt(), isNaN(), isFinite(), etc. as methods of the Global object. "Constants" like Nan, Infinity, etc. are also attributes of the Global object. The constructors of built-in global objects such as Boolean, String, Number, RegExp, etc. are also properties of the Global object. But the Global object does not actually exist, which means that if you use Global.NaN to access NaN, an error will be reported. In fact, it is the window that plays this role, and this process is performed when the javascript is first loaded.
Okay, okay, that’s it. Originally there was another part, forget it, let’s talk about it in another section later.