DOM的基本结构:

几点说明:
1.DOM的根节点是Document文档,每个载入浏览器的 HTML 文档都会成为 Document 对象,window.document代表了这个对象,也可以用所有基本元素节点的ownerDocument属性获取这个对象。
2.html节点是第二级节点,包含了head和body两个元素节点。
HTML中基本元素拥有的属性(W3C: W3C Standard.)
Property | Description | W3C |
---|---|---|
attributes[] | 获取一个元素的所有属性组成的数组 | Yes |
childNodes[] | 获取一个元素的所有子节点组成的数组 | Yes |
accessKey | 设置或获取一个元素的快捷键 | Yes |
className | Sets or returns the class attribute of an element | Yes |
clientHeight | Returns the viewable height of the content on a page (not including borders, margins, or scrollbars) | Yes |
clientWidth | Returns the viewable width of the content on a page (not including borders, margins, or scrollbars) | Yes |
dir | Sets or returns the text direction of an element | Yes |
disabled | Sets or returns whether an element is disabled, or not | Yes |
firstChild | Returns the first child of an element | Yes |
height | 设置或获取元素的高度属性 | Yes |
id | Sets or returns the id of an element | Yes |
innerHTML | Sets or returns the HTML contents (+text) of an element | Yes |
lang | Sets or returns the language code for an element | Yes |
lastChild | 获取一个元素的最后一个子元素 | Yes |
length | Yes | |
nextSibling | 获取紧邻元素之后的元素 | Yes |
nodeName | 获取元素的节点名称 (以大写方式) | Yes |
nodeType | 获取元素的节点类型 | Yes |
nodeValue | 获取元素的值 | Yes |
offsetHeight | Returns the height of an element, including borders and padding if any, but not margins | No |
offsetLeft | Returns the horizontal offset position of the current element relative to its offset container | Yes |
offsetParent | Returns the offset container of an element | Yes |
offsetTop | Returns the vertical offset position of the current element relative to its offset container | Yes |
offsetWidth | 获取一个元素的宽度,包括补白和边框,不包括边界 | No |
ownerDocument | 获取一个元素所属的根文档(Document对象) | Yes |
parentNode | 获取一个元素的父节点 | Yes |
previousSibling | 获取紧邻元素之前的元素 | Yes |
scrollHeight | 获取元素的整体高度(包括滚动条) | Yes |
scrollLeft | Returns the distance between the actual left edge of an element and its left edge currently in view | Yes |
scrollTop | Returns the distance between the actual top edge of an element and its top edge currently in view | Yes |
scrollWidth | 获取元素的整体宽度(包括滚动条) | Yes |
style | 设置或获取元素的样式属性 | Yes |
tabIndex | 设置或获取元素的TAB顺序 | Yes |
tagName | 以大写字符串的方式获取元素的标签名 | Yes |
title | 设置或获取元素的标题属性 | Yes |
width | 设置或获取元素的宽度属性 | Yes |
html中基本元素拥有的方法:
Method | Description | W3C |
---|---|---|
appendChild() | 在子元素列表后面增加一个新的元素 | Yes |
blur() | 从一个元素上移除焦点 | Yes |
click() | 在一个元素上执行点击操作 | Yes |
cloneNode() | 复制元素 | Yes |
focus() | 让一个元素成为焦点 | Yes |
getAttribute() | Returns the value of an attribute | Yes |
getElementsByTagName() | 根据指定的标签名获取所有元素 | Yes |
hasChildNodes() | 返回一个元素是否有子元素 | Yes |
insertBefore() | 在现存的子元素前插入一个新的子元素 | Yes |
item() | 基于文档树的位置返回一个元素 | Yes |
normalize() | Puts all text nodes underneath this element (including attributes) into a "normal" form where only structure (e.g., elements, comments, processing instructions, CDATA sections, and entity references) separates Text nodes, i.e., there are neither adjacent Text nodes nor empty Text nodes | Yes |
removeAttribute() | 从元素中移除指定的属性 | Yes |
removeChild() | 移除一个子元素 | Yes |
replaceChild() | 替换一个子元素 | Yes |
setAttribute() | 为元素增加新的属性 | Yes |
toString() | 将一个元素转化为字符串 | Yes |
没有评论:
发表评论