http://www.w3.org/wiki/DOM/domcore/Element
DOM/domcore/Element
Element
The Element interface represents an element in an HTML or XML document. Elements may have attributes associated with them; since the Element interface inherits from Node, the generic Node interface attribute attributes may be used to retrieve the set of all attributes for an element.
Attributes
| Name | Description |
|---|---|
namespaceURI | ... |
prefix | ... |
localName | ... |
tagName | Returns the name of the element. |
attributes | ... |
children | ... |
firstElementChild | ... |
lastElementChild | ... |
previousElementSibling | ... |
nextElementSibling | ... |
childElementCount | ... |
Methods
| Name | Description |
|---|---|
getAttribute(name) | Retrieves an attribute value by name. |
getAttributeNS(namespace, localName) | Retrieves an attribute value by local name and namespace URI. |
setAttribute(qualifiedName, value) | Adds a new attribute. |
setAttributeNS(namespace, qualifiedName, value) | Adds a new attribute. |
removeAttribute(qualifiedName) | Removes an attribute by name. |
removeAttributeNS(namespace, localName) | Removes an attribute by local name and namespace URI. |
hasAttribute(qualifiedName) | Returns true when an attribute with a given name is specified on this element or has a default value, false otherwise. |
hasAttributeNS(namespace, localName) | Returns true when an attribute with a given local name and namespace URI is specified on this element or has a default value, false otherwise. |
getElementsByTagName(qualifiedName) | Returns a list of all descendant Elements with a given tag name, in document order. |
getElementsByTagNameNS(namespace, localName) | Returns a list of all the descendant Elements with a given local name and namespace URI in document order. |
getElementsByClassName(classNames) | Returns the Element that has an class attribute with the given value. |
本文深入探讨了DOM核心中的Element接口,包括属性、方法和DOM核心引用等内容。重点介绍了Element对象如何代表HTML或XML文档中的元素,以及如何通过属性和方法操作这些元素。
242

被折叠的 条评论
为什么被折叠?



