2011年3月2日星期三

DOM结构以及HTML中的基本元素

DOM的基本结构:


DOM树

几点说明:
1.DOM的根节点是Document文档,每个载入浏览器的 HTML 文档都会成为 Document 对象,window.document代表了这个对象,也可以用所有基本元素节点的ownerDocument属性获取这个对象。
2.html节点是第二级节点,包含了head和body两个元素节点。

HTML中基本元素拥有的属性(W3C: W3C Standard.)






























































































































































































PropertyDescriptionW3C
attributes[]获取一个元素的所有属性组成的数组Yes
childNodes[]获取一个元素的所有子节点组成的数组Yes
accessKey设置或获取一个元素的快捷键Yes
classNameSets or returns the class attribute of an elementYes
clientHeightReturns the viewable height of the content on a page (not including

borders, margins, or scrollbars)
Yes
clientWidthReturns the viewable width of the content on a page (not including

borders, margins, or scrollbars)
Yes
dirSets or returns the text direction of an elementYes
disabledSets or returns whether an element is disabled, or notYes
firstChildReturns the first child of an elementYes
height设置或获取元素的高度属性Yes
idSets or returns the id of an elementYes
innerHTMLSets or returns the HTML contents (+text) of an elementYes
langSets or returns the language code for an elementYes
lastChild获取一个元素的最后一个子元素Yes
lengthYes
nextSibling获取紧邻元素之后的元素Yes
nodeName获取元素的节点名称 (以大写方式)Yes
nodeType获取元素的节点类型Yes
nodeValue获取元素的值Yes
offsetHeightReturns the height of an element, including borders and padding if any,

but not margins
No
offsetLeftReturns the horizontal offset position of the current element relative

to its offset container
Yes
offsetParentReturns the offset container of an elementYes
offsetTopReturns 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
scrollLeftReturns the distance between the actual left edge of an element and its

left edge currently in view
Yes
scrollTopReturns 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中基本元素拥有的方法:
























































































MethodDescriptionW3C
appendChild()在子元素列表后面增加一个新的元素Yes
blur()从一个元素上移除焦点Yes
click()在一个元素上执行点击操作Yes
cloneNode()复制元素Yes
focus()让一个元素成为焦点Yes
getAttribute()Returns the value of an attributeYes
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

没有评论:

发表评论