html dom
NodesAccording to the DOM, everything in an HTML document is a node.
根据dom,html文件中的所有东西都是node。
The DOM says:
The entire document is a document node 整个文档是document node。
Every HTML tag is an element node 任何html tag是一个element node。
The text in the HTML elements are text nodes。element中间的文本是text node。不属于element node。但是可以通过innerHTML来操作。
Every HTML attribute is an attribute node。所有的属性是attribute node。
Comments are comment nodes 。注释是comment node。 <title>DOM Tutorial</title>, the element node <title>, holds a text node with the value "DOM Tutorial".
"DOM Tutorial" is not the value of the <title> element!
dom的javascript编程界面。所谓编程界面就是一组属性和方法。一下是一些标准的属性:
[list=1]
[*]x.innerHTML - the inner text value of x (a HTML element)
[*]x.nodeName - the name of x
[*]x.nodeValue - the value of x
[*]x.parentNode - the parent node of x
[*]x.childNodes - the child nodes of x
[*]x.attributes - the attributes nodes of x
[/list]
一些标准的方法:
[list=1]
[*]x.getElementByID(id) - get the element with a specified id
[*]x.getElementsByTagName(name) - get all elements with a specified tag name
[*]x.appendChild(node) - insert a child node to x
[*]x.removeChild(node) - remove a child node from x
[/list]
页:
[1]
