属性

 


attributes
返回元素的属性集合. (DOM Core)(No IE)
childNodes
返回包含当前元素的子元素的列表. (DOM Core)
className
获取/设置元素的类别. (HTML, XUL, ...)
clientHeight
元素内部的高度. (HTML-specific)
clientLeft
The width of the left border of an element in pixels. 不被普遍的支持. (HTML-specific)
clientTop
The width of the top border of an element in pixels. 不被普遍的支持. (HTML-specific)
clientWidth
元素内部的宽度. (HTML-specific)
dir
获取/设置元素的方向. (HTML, XUL)
firstChild
返回当前元素第一个子元素. (DOM Core)
id
获取/设置元素的id. (HTML, XUL, ...)
innerHTML
获取/设置元素内部的HTML标记和内容. (HTML-specific)
lang
指定元素的属性值和文本内容的语言. (HTML-specific)
lastChild
返回当前元素最后一个子元素.(DOM Core)
length
返回列表内元素的数量.(例如:childNodes). (DOM Core, not part of Element interface)
localName
Returns the local part of the qualified name of this node. (DOM Core)
name
获取/设置元素的name属性—并非所有此属性. (HTML-specific)
namespaceURI
节点的命名空间 URI, 如果没有指定则为 null. (DOM Core)
nextSibling
返回节点的下一个兄弟节点. (DOM Core)
nodeName
返回节点的名称. (DOM Core)
nodeType
返回节点的类型. (DOM Core)
nodeValue
返回节点的值. (DOM Core)
offsetHeight
返回元素的高度相对布局. (HTML-specific)
offsetLeft
获取元素的左边界到它的offsetParent节点的左边界的水平距离(单位像素). (HTML-specific)
offsetParent
Returns a reference to the object in which the current element is offset (i.e., the parent element). (HTML-specific)
offsetTop
获取元素的上边界到它的offsetParent节点的上边界的垂直距离(单位像素). (HTML-specific)
offsetWidth
返回元素的宽度相对布局. (HTML-specific)
ownerDocument
返回元素所在的document对像. (DOM Core)
parentNode
返回元素的父亲节点. (DOM Core)
prefix
返回当前元素的命名空间前缀, 如果未指定则返回 null. (DOM Core)
previousSibling
Returns the node immediately previous to the given one in the tree. (DOM Core)
scrollHeight
Returns the height of the scroll view of an element. (HTML-specific)
scrollLeft
Gets or sets the number of pixels that an element's content is scrolled to the left. (HTML-specific)
scrollTop
Gets/sets the distance between the top of an element and the topmost portion of its content currently visible. (HTML-specific)
scrollWidth
Returns the width of the scroll view of an element. (HTML-specific)
style
Returns an object representing the declarations in the the element's style attribute. (HTML, XUL, ...)
tabIndex
获取/设置元素的TAB次序. (HTML)
tagName
返回元素的标签名称. (DOM Core)
textContent
Gets/sets the text content of an element including its descendants. (DOM Core)

方法

addEventListener
Allows the registration of event listeners on the event target. (DOM Events)
appendChild
Inserts the specified node into the list of nodes on the current document. (DOM Core)
blur
将键盘焦点从当前元素上移开. (HTML, XUL)
click
在当前元素上模拟一次单击. (HTML, XUL)
cloneNode
Returns a duplicate of the current node. (DOM Core)
dispatchEvent
Allows the dispatch of events into the implementation's event model. (DOM Events)
focus
使当前元素获得焦点. (HTML, XUL)
getAttribute
返回当前节点中指定属性的值. (DOM Core)
getAttributeNS
Returns the value of the attribute with the given name and namespace. (DOM Core)
getAttributeNode
Returns the attribute of the element as a separate node. (DOM Core)
getAttributeNodeNS
A namespace-aware version of getAttributeNode (DOM Core)
getElementsByTagName
Returns the elements of a particular tag name that are descendants of the current element. (DOM Core)
hasAttribute
Returns a boolean value indicating whether the element has the specified attribute or not. (DOM Core)
hasAttributeNS
Returns a boolean value indicating whether the element has an attribute with the specified name and namespace. (DOM Core)
hasAttributes
Returns a boolean value indicating whether the element has any attributes. (DOM Core)
hasChildNodes
Returns boolean value indicating whether the current element has children or not. (DOM Core)
insertBefore
Inserts a node before the current element in the DOM. (DOM Core)
item
Retrieves a node from a NodeList by index. (DOM Core, not part of the Element interface)
normalize
Puts the node and all of its subtree into a "normalized" form. (DOM Core)
removeAttribute
Removes an attribute from the element. (DOM Core)
removeAttributeNS
Removes the attribute with specified name and namespace from the element. (DOM Core)
removeAttributeNode
Removes the specified attribute from the element. (DOM Core)
removeChild
Removes a child node from the current element. (DOM Core)
removeEventListener
Removes an event listener from the element. (DOM Events)
replaceChild
Replaces one child node on the current element with another. (DOM Core)
scrollIntoView
Scrolls the page until the element gets into the view. (HTML)
setAttribute
Adds a new attribute or changes the value of an existing attribute on the current element. (DOM Core)
setAttributeNS
Adds a new attribute or changes the value of an attribute with the given namespace and name. (DOM Core)
setAttributeNode
Adds a new attribute node to the current element. (DOM Core)
setAttributeNodeNS
Adds a new attribute node with the specified namespace and name. (DOM Core)
supports
Tests if this DOM implementation supports a particular feature.

事件句柄

对应HTML中的 'onxxx' 事件, 有一些相应的属性.

不像其他的属性, 这些属性是一些函数 (或其他实现了 EventListener 接口的对象) 而不是字符串. 事实上, 在HTML里分配一个事件就创建一个指定代码的函数包装. 比如以下的HTML代码:

<div onclick="foo();">点我!</div>

假设 element 是指向这一个 div 的引用, 那么 element.onclick 相当于下面的效果:

function onclick(event) {
foo();
}

Note how the event object is passed as parameter event to this wrapper function.

onblur
Returns the event handling code for the blur event.
onclick
Returns the event handling code for the click event.
ondblclick
Returns the event handling code for the dblclick event.
onfocus
Returns the event handling code for the focus event.
onkeydown
Returns the event handling code for the keydown event.
onkeypress
Returns the event handling code for the keypress event.
onkeyup
Returns the event handling code for the keyup event.
onmousedown
Returns the event handling code for the mousedown event.
onmousemove
Returns the event handling code for the mousemove event.
onmouseout
Returns the event handling code for the mouseout event.
onmouseover
Returns the event handling code for the mouseover event.
onmouseup
Returns the event handling code for the mouseup event.
onresize
Returns the event handling code for the resize event.