[HTML API]Element
interface Element : Node {
readonly attribute DOMString? namespaceURI;
readonly attribute DOMString? prefix;
readonly attribute DOMString localName;
readonly attribute DOMString tagName;
attribute DOMString id;
attribute DOMString className;
readonly attribute DOMTokenList classList;
readonly attribute Attr[] attributes;
DOMString? getAttribute(DOMString name);
DOMString? getAttributeNS(DOMString? namespace, DOMString localName);
void setAttribute(DOMString name, DOMString value);
void setAttributeNS(DOMString? namespace, DOMString name, DOMString value);
void removeAttribute(DOMString name);
void removeAttributeNS(DOMString? namespace, DOMString localName);
boolean hasAttribute(DOMString name);
boolean hasAttributeNS(DOMString? namespace, DOMString localName);
NodeList getElementsByTagName(DOMString qualifiedName);
NodeList getElementsByTagNameNS(DOMString? namespace, DOMString localName);
NodeList getElementsByClassName(DOMString classNames);
readonly attribute HTMLCollection children;
readonly attribute Element? firstElementChild;
readonly attribute Element? lastElementChild;
readonly attribute Element? previousElementSibling;
readonly attribute Element? nextElementSibling;
readonly attribute unsigned long childElementCount;
// 新特性
void prepend((Node or DOMString)... nodes);
void append((Node or DOMString)... nodes);
void before((Node or DOMString)... nodes);
void after((Node or DOMString)... nodes);
void replace((Node or DOMString)... nodes);
void remove();
};
namespaceURI
释义
namespaceURI属性必须返回其上下文对象的命名空间。
兼容性状态
| IE 6 | 不支持。 |
|---|---|
| IE 7/8 | 不支持。 |
| IE 9+ | |
| Chrome | 支持。 |
| Firefox | 支持。 |
| Safari |
prefix
释义
prefix属性必须返回其上下文对象的命名空间前缀。
兼容性状态
| IE 6 | 不支持。 |
|---|---|
| IE 7/8 | 不支持。 |
| IE 9+ | |
| Chrome | 支持。 |
| Firefox | 支持。 |
| Safari |
localName
释义
localName属性必须返回其上下文对象的本地名称。
兼容性状态
| IE 6 | 不支持。 |
|---|---|
| IE 7/8 | 不支持。 |
| IE 9+ | |
| Chrome | 支持。 |
| Firefox | 支持。 |
| Safari |
tagName
释义
tagName属性必须返回其完整标记名称。
兼容性状态
| IE 6 | 支持。 |
|---|---|
| IE 7/8 | 支持。 |
| IE 9+ | |
| Chrome | 支持。 |
| Firefox | 支持。 |
| Safari |
id
释义
id属性必须反映“id”内容属性。
兼容性状态
| IE 6 | 支持。 |
|---|---|
| IE 7/8 | 支持。 |
| IE 9+ | |
| Chrome | 支持。 |
| Firefox | 支持。 |
| Safari |
className
释义
className属性必须反映“class”内容属性。
兼容性状态
| IE 6 | 支持。 |
|---|---|
| IE 7/8 | 支持。 |
| IE 9+ | |
| Chrome | 支持。 |
| Firefox | 支持。 |
| Safari |
classList
释义
classList属性必须返回一个基础字符串为其className属性值的DOMTokenList。
兼容性状态
| IE 6 | 不支持。 |
|---|---|
| IE 7/8 | 不支持。 |
| IE 9+ | |
| Chrome | 支持。 |
| Firefox | 支持。 |
| Safari |
attributes
释义
attributes属性必须返回一个与其上下文对象相关的属性的只读数组。返回的只读数组必须是实时的。例如,需要反映对与其相关的属性的修改。
兼容性状态
| IE 6 | 支持。 |
|---|---|
| IE 7/8 | 支持。 |
| IE 9+ | |
| Chrome | 支持。 |
| Firefox | 支持。 |
| Safari |
getAttribute(name)
释义
getAttribute方法必须返回其上下文对象的属性列表中名称为name的第一个属性的值,否则返回空。
兼容性状态
| IE 6 | 支持。 |
|---|---|
| IE 7/8 | 支持。 |
| IE 9+ | |
| Chrome | 支持。 |
| Firefox | 支持。 |
| Safari |
setAttribute(name, value)
释义
setAttribute方法必须创建或修改其上下文对象的属性列表中名称为name的第一个属性,将其值设为value。
兼容性状态
| IE 6 | 支持。 |
|---|---|
| IE 7/8 | 支持。 |
| IE 9+ | |
| Chrome | 支持。 |
| Firefox | 支持。 |
| Safari |
removeAttribute(name)
释义
removeAttribute方法必须移除其上下文对象的属性列表中名称为name的属性。
兼容性状态
| IE 6 | 支持。 |
|---|---|
| IE 7/8 | 支持。 |
| IE 9+ | |
| Chrome | 支持。 |
| Firefox | 支持。 |
| Safari |
hasAttribute(name)
释义
如果上下文对象的属性列表中存在一个名称为name的属性,则hasAttribute方法必须返回真,否则必须返回假。
兼容性状态
| IE 6 | 支持。 |
|---|---|
| IE 7/8 | 支持。 |
| IE 9+ | |
| Chrome | 支持。 |
| Firefox | 支持。 |
| Safari |
getElementsByTagName(qualifiedName)
释义
getElementsByTagName方法必须返回其上下文对象中本地名称为qualifiedName的元素的列表。
兼容性状态
| IE 6 | 不支持。 |
|---|---|
| IE 7/8 | 支持。返回HTMLCollection对象。 |
| IE 9+ | |
| Chrome | 支持。 |
| Firefox | 支持。返回HTMLCollection对象。 |
| Safari |
getElementsByClassName(classNames)
释义
当调用getElementsByClassName(classNames)方法时,必须返回一个NodeList,其元素为在上下文对象的节点文档上通过传递相同参数调用getElementsByClassName()方法所返回的,除去任意不是调用该方法的上下文对象的后裔的元素。
兼容性状态
| IE 6 | 不支持。 |
|---|---|
| IE 7/8 | 不支持。 |
| IE 9+ | |
| Chrome | 支持。 |
| Firefox | 支持。返回HTMLCollection对象。 |
| Safari |
children
释义
children属性必须返回一个植根于上下文对象仅匹配元素孩子的HTMLCollection集合。
兼容性状态
| IE 6 | 支持。返回Object。 |
|---|---|
| IE 7/8 | 支持。 |
| IE 9+ | |
| Chrome | 支持。 |
| Firefox | 支持。 |
| Safari |
firstElementChild
释义
firstElementChild属性必须返回第一个是元素的孩子,否则必须返回空。
兼容性状态
| IE 6 | 不支持。 |
|---|---|
| IE 7/8 | 不支持。 |
| IE 9+ | |
| Chrome | 支持。 |
| Firefox | 支持。 |
| Safari |
lastElementChild
释义
lastElementChild属性必须返回最后一个是元素的孩子,否则必须返回空。
兼容性状态
| IE 6 | 不支持。 |
|---|---|
| IE 7/8 | 不支持。 |
| IE 9+ | |
| Chrome | 支持。 |
| Firefox | 支持。 |
| Safari |
previousElementSibling
释义
previousElementSibling属性必须返回最近的是元素的之前的兄弟,否则必须返回空。
兼容性状态
| IE 6 | 不支持。 |
|---|---|
| IE 7/8 | 不支持。 |
| IE 9+ | |
| Chrome | 支持。 |
| Firefox | 支持。 |
| Safari |
nextElementSibling
释义
nextElementSibling属性必须返回最近的是元素的之后的兄弟,否则必须返回空。
兼容性状态
| IE 6 | 不支持。 |
|---|---|
| IE 7/8 | 不支持。 |
| IE 9+ | |
| Chrome | 支持。 |
| Firefox | 支持。 |
| Safari |
childElementCount
释义
childElementCount属性必须返回上下文对象中是元素的孩子数目。
兼容性状态
| IE 6 | 不支持。 |
|---|---|
| IE 7/8 | 不支持。 |
| IE 9+ | |
| Chrome | 支持。 |
| Firefox | 支持。 |
| Safari |
prepend(nodes)
释义
prepend方法必须向上下文对象中在上下文对象的第一个孩子之前预插入node。
兼容性状态
| IE 6 | 不支持。 |
|---|---|
| IE 7/8 | 不支持。 |
| IE 9+ | |
| Chrome | 不支持。 |
| Firefox | 不支持。 |
| Safari |
append(nodes)
释义
append方法必须向上下文对象中追加node。
兼容性状态
| IE 6 | 不支持。 |
|---|---|
| IE 7/8 | 不支持。 |
| IE 9+ | |
| Chrome | 不支持。 |
| Firefox | 不支持。 |
| Safari |
before(nodes)
释义
before方法必须向上下文对象的父亲中在上下文对象之前预插入node。
兼容性状态
| IE 6 | 不支持。 |
|---|---|
| IE 7/8 | 不支持。 |
| IE 9+ | |
| Chrome | 不支持。 |
| Firefox | 不支持。 |
| Safari |
after(nodes)
释义
after方法必须向上下文对象的父亲中在上下文对象的下一个兄弟之前预插入node。
兼容性状态
| IE 6 | 不支持。 |
|---|---|
| IE 7/8 | 不支持。 |
| IE 9+ | |
| Chrome | 不支持。 |
| Firefox | 不支持。 |
| Safari |
replace(nodes)
释义
replace方法必须在上下文对象中将上下文对象替换为node。
兼容性状态
| IE 6 | 不支持。 |
|---|---|
| IE 7/8 | 不支持。 |
| IE 9+ | |
| Chrome | 不支持。 |
| Firefox | 不支持。 |
| Safari |
remove()
释义
remove方法必须从上下文对象的父亲中移除上下文对象。
兼容性状态
| IE 6 | 不支持。 |
|---|---|
| IE 7/8 | 不支持。 |
| IE 9+ | |
| Chrome | 不支持。 |
| Firefox | 不支持。 |
| Safari |