Element
Module: JavaScript DOM API
a element in the view
#include <Element.idl>
Inherits from Node, EventTarget
Inherited by HTMLElement, SVGElement
Public Functions
Name | |
---|---|
void | setAttribute(DOMString qualifiedName, DOMString value) sets the given attribute name to the specified value |
void | setAttributeNS(DOMString ns, DOMString qualifiedName, DOMString value) sets the given attribute name to the specified value |
void | removeAttribute(DOMString qualifiedName) removes the specified attribute |
void | removeAttributeNS(DOMString ns, DOMString qualifiedName) removes the specified attribute |
DOMString | getAttribute(DOMString qualifiedName) returns the attribute value for the given qualified name |
DOMString | getAttributeNS(DOMString ns, DOMString qualifiedName) returns the attribute value for the given qualified name |
boolean | hasAttribute(DOMString qualifiedName) returns whether the element has an attribute with the given qualified name |
boolean | hasAttributeNS(DOMString ns, DOMString qualifiedName) returns whether the element has an attribute with the given qualified name |
Attr | getAttributeNode(DOMString qualifiedName) Returns the specified attribute of the specified element, as an Attr node. |
Attr | getAttributeNodeNS(DOMString? namespace, DOMString localName) Returns the Attr node for the attribute with the given namespace and name. |
Attr | setAttributeNode(Attr attr) Adds a new Attr node to the specified element. |
Attr | setAttributeNodeNS(Attr attr) Adds a new namespaced attribute node to an element. |
Attr | removeAttributeNode(Attr attr) Removes the specified attribute from the current element. |
boolean | hasAttributes() Returns Boolean value, indicating if the current element has any attributes or not. |
sequenceDOMString | getAttributeNames() Must return the qualified names of the attributes in context objects attribute list, in order, and a new list otherwise. |
HTMLCollection | getElementsByTagName(DOMString qualifiedName) Returns the list of elements with qualified name qualifiedName for context object. |
HTMLCollection | getElementsByTagNameNS(DOMString? namespace, DOMString localName) Return the list of elements with namespace namespace and local name localName for. |
HTMLCollection | getElementsByClassName(DOMString classNames) Return the list of elements with class names classNames for context object. |
Element | insertAdjacentElement(DOMString where, Element element) Inserts a given element node at a given position relative to the element it is invoked upon. |
void | insertAdjacentText(DOMString where, DOMString data) Inserts a given text node at a given position relative to the element it is invoked upon. |
Element | closest(DOMString selectors) Returns the closest ancestor of the current element (or the current element itself) which matches the selectors given in parameter. If there isn’t such an ancestor, it returns null. |
boolean | matches(DOMString selectors) Returns true if the element would be selected by the specified selector string; otherwise, returns false. |
void | blur() Removes keyboard focus from this element. |
void | focus() Gives keyboard focus to this element. |
void | insertAdjacentHTML(DOMString position, DOMString text) Parses the specified text as HTML or XML and inserts the resulting nodes into the DOM tree at a specified position. |
Element | querySelector(DOMString selectors) Returns the first element that is a descendant of the element on which it is invoked that matches the specified group of selectors. |
NodeList | querySelectorAll(DOMString selectors) Returns a static (not live) NodeList of all elements descended from the element on which it is invoked that matches the specified group of CSS selectors. (The base element itself is not included, even if it matches.) |
sequence< Animation > | getAnimations(optional GetAnimationsOptions options) Returns an array of all the Animation objects that the element has. |
DOMRect | getBoundingClientRect() Returns the bounding rectangle of the element. |
DOMRectList | getClientRects() Returns a collection of the bounding rectangles for each CSS border box in the element. |
void | remove() Removes node Note: This should be part of the ChildNode interface. |
Public Attributes
Name | |
---|---|
readonly attribute DOMString | tagName the element tag |
readonly attribute DOMString | prefix Returns the namespace prefix of the specified element, or null if no prefix is specified. |
readonly attribute DOMString | namespaceURI Returns the namespace URI of the element, or null if the element is not in a namespace. |
readonly attribute DOMString | localName returns the local part of the qualified name of an element. |
attribute DOMString | slot Returns the name of the shadow DOM slot attached to the element. A slot is a placeholder inside a web component that users can fill with their own markup. |
attribute DOMString | id the id of the element |
readonly attribute long | clientTop Returns the unscaled width of the top border of the element in pixels, ignoring any transforms. |
readonly attribute long | clientLeft Returns the unscaled width of the left border of the element in pixels, ignoring any transforms. |
readonly attribute long | clientWidth Returns the unscaled width of the padding box of the element, ignoring any transforms. |
readonly attribute long | clientHeight Returns the unscaled height of the padding box of the element, ignoring any transforms. |
readonly attribute NamedNodeMap | attributes Gets a list of all attributes for the Element. |
readonly attribute NodeList | children A collection rooted at context object matching only element children. Note: This should be part of the ParentNode interface, which Element implements. Note: The return type should be HTMLCollection. |
readonly attribute Element | firstElementChild attributes getter must return the first child that is an element, and null otherwise. Note: This should be part of the ParentNode interface, which Element |
readonly attribute Element | lastElementChild attributes getter must return the last child that is an element, and null otherwise. Note: This should be part of the ParentNode interface, which Element |
readonly attribute Element | previousElementSibling Returns the Element immediately prior to this node in its parent’s children list, or null if there is no Element in the list prior to this node. Note: This attribute is part of the NonDocumentTypeChildNode interface, which Element implements. |
readonly attribute Element | nextElementSibling Returns the Element immediately following this node in its parent’s children list, or null if there is no Element in the list following this node. Note: This attribute is part of the NonDocumentTypeChildNode interface, which Element implements. |
readonly attribute unsigned long | childElementCount attributes getter must return the number of children of context object that are elements. Note: This should be part of the ParentNode interface, which Element |
attribute float | scrollLeft position of the horizontal scrollbar of the element |
attribute float | scrollLeftVW scrollLeft in VW units The setter converts a given value into PX units based on viewport size |
attribute float | scrollLeftVH scrollLeft in VH units The setter converts a given value into PX units based on viewport size |
attribute float | scrollTop position of the vertical scrollbar of the element |
attribute float | scrollTopVW scrollTop in VW units The setter converts a given value into PX units based on viewport size |
attribute float | scrollTopVH scrollTop in VH units The setter converts a given value into PX units based on viewport size |
readonly attribute long | scrollWidth size of the horizontal scrollbar of the element |
readonly attribute long | scrollWidthVW scrollWidth converted to VW units |
readonly attribute long | scrollWidthVH scrollWidth converted to VH units |
readonly attribute long | scrollHeight size of the vertical scrollbar of the element |
readonly attribute long | scrollHeightVW scrollHeight converted to VH units |
readonly attribute long | scrollHeightVH scrollHeight converted to VH units |
attribute DOMString | className all of the classes of the element |
readonly attribute DOMTokenList | classList |
attribute DOMString | innerHTML Gets or sets the contents of the element as HTML. |
attribute DOMString | outerHTML Gets a fragment of HTML or XML that represents the element and its contents. |
attribute EventSetter | focusin |
attribute EventSetter | focusout |
attribute EventSetter | abort |
attribute EventSetter | blur |
attribute EventSetter | click |
attribute EventSetter | auxclick |
attribute EventSetter | dblclick |
attribute EventSetter | error |
attribute EventSetter | focus |
attribute EventSetter | keydown |
attribute EventSetter | keypress |
attribute EventSetter | keyup |
attribute EventSetter | load |
attribute EventSetter | mousedown |
attribute EventSetter | mouseover |
attribute EventSetter | mouseout |
attribute EventSetter | mouseenter |
attribute EventSetter | mouseleave |
attribute EventSetter | mousemove |
attribute EventSetter | mouseup |
attribute EventSetter | input |
attribute EventSetter | change |
attribute EventSetter | scroll |
attribute EventSetter | wheel |
attribute EventSetter | touchstart |
attribute EventSetter | touchend |
attribute EventSetter | touchmove |
attribute EventSetter | animationstart |
attribute EventSetter | animationend |
attribute EventSetter | animationcancel |
attribute EventSetter | animationiteration |
attribute EventSetter | transitionstart |
attribute EventSetter | transitionend |
attribute EventSetter | transitioncancel |
attribute EventSetter | transitionrun |
Additional inherited members
Public Functions inherited from Node
Name | |
---|---|
Node | removeChild(Node oldChild) remove a child node |
Node | appendChild(Node newChild) append a node as a child |
void | append((Node or DOMString)… newChildren) append nodes and string objects as children, where the string objects are inserted as equivalent Text nodes |
Node | replaceChild(Node newChild, Node oldChild) replace oldChild with newChild |
Node | insertBefore(Node node, Node? referenceNode) insert a node before the reference node, as a child of the current node |
Node | cloneNode(optional boolean deep =false) |
boolean | isEqualNode(Node? otherNode) |
boolean | isSameNode(Node? otherNode) |
boolean | hasChildNodes() |
boolean | contains(Node? other) |
DOMString | lookupPrefix(DOMString? namespace) |
boolean | isDefaultNamespace(DOMString? namespace) |
void | normalize() |
unsigned short | compareDocumentPosition(Node other) |
Node | getRootNode(optional GetRootNodeOptions options) |
DOMString | lookupNamespaceURI(DOMString? prefix) |
Public Attributes inherited from Node
Name | |
---|---|
const unsigned short | ELEMENT_NODE |
const unsigned short | ATTRIBUTE_NODE |
const unsigned short | TEXT_NODE |
const unsigned short | CDATA_SECTION_NODE |
const unsigned short | ENTITY_REFERENCE_NODE |
const unsigned short | ENTITY_NODE |
const unsigned short | PROCESSING_INSTRUCTION_NODE |
const unsigned short | COMMENT_NODE |
const unsigned short | DOCUMENT_NODE |
const unsigned short | DOCUMENT_TYPE_NODE |
const unsigned short | DOCUMENT_FRAGMENT_NODE |
const unsigned short | NOTATION_NODE |
const unsigned short | DOCUMENT_POSITION_DISCONNECTED |
const unsigned short | DOCUMENT_POSITION_PRECEDING |
const unsigned short | DOCUMENT_POSITION_FOLLOWING |
const unsigned short | DOCUMENT_POSITION_CONTAINS |
const unsigned short | DOCUMENT_POSITION_CONTAINED_BY |
const unsigned short | DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC |
readonly attribute DOMString | nodeName |
attribute DOMString | nodeValue |
attribute DOMString | textContent |
readonly attribute unsigned short | nodeType type of the node |
readonly attribute Node | parentNode parent of the node |
readonly attribute Element | parentElement parent element of the node. If parent is not an Element, returns null. |
readonly attribute NodeList | childNodes list of the children of this node |
readonly attribute Node | firstChild the node’s first child in the tree, or null if the node is childless |
readonly attribute Node | lastChild last child of the node, or null if there are no child elements |
readonly attribute Node | previousSibling the node immediately preceding the specified one in its parent’s children, or null if the specified node is the first in that list |
readonly attribute Node | nextSibling the node immediately following the specified one in its parent’s children, or null if the specified node is the last node in that list |
readonly attribute Document | ownerDocument The Document object associated with this node. This is also the Document object used to create new nodes. When this node is a Document or a DocumentType which is not used with any Document yet, this is null. |
readonly attribute USVString | baseURI |
readonly attribute boolean | isConnected |
Public Functions inherited from EventTarget
Name | |
---|---|
void | addEventListener(DOMInternedString type, EventListener listener, optional boolean useCapture) |
void | removeEventListener(DOMInternedString type, EventListener listener, optional boolean useCapture) |
boolean | dispatchEvent(Event event) |
Public Functions Documentation
function setAttribute
void setAttribute(
DOMString qualifiedName,
DOMString value
)
sets the given attribute name to the specified value
function setAttributeNS
void setAttributeNS(
DOMString ns,
DOMString qualifiedName,
DOMString value
)
sets the given attribute name to the specified value
function removeAttribute
void removeAttribute(
DOMString qualifiedName
)
removes the specified attribute
function removeAttributeNS
void removeAttributeNS(
DOMString ns,
DOMString qualifiedName
)
removes the specified attribute
function getAttribute
DOMString getAttribute(
DOMString qualifiedName
)
returns the attribute value for the given qualified name
function getAttributeNS
DOMString getAttributeNS(
DOMString ns,
DOMString qualifiedName
)
returns the attribute value for the given qualified name
function hasAttribute
boolean hasAttribute(
DOMString qualifiedName
)
returns whether the element has an attribute with the given qualified name
function hasAttributeNS
boolean hasAttributeNS(
DOMString ns,
DOMString qualifiedName
)
returns whether the element has an attribute with the given qualified name
function getAttributeNode
Attr getAttributeNode(
DOMString qualifiedName
)
Returns the specified attribute of the specified element, as an Attr node.
function getAttributeNodeNS
Attr getAttributeNodeNS(
DOMString? namespace,
DOMString localName
)
Returns the Attr node for the attribute with the given namespace and name.
function setAttributeNode
Attr setAttributeNode(
Attr attr
)
Adds a new Attr node to the specified element.
function setAttributeNodeNS
Attr setAttributeNodeNS(
Attr attr
)
Adds a new namespaced attribute node to an element.
function removeAttributeNode
Attr removeAttributeNode(
Attr attr
)
Removes the specified attribute from the current element.
function hasAttributes
boolean hasAttributes()
Returns Boolean value, indicating if the current element has any attributes or not.
function getAttributeNames
sequenceDOMString getAttributeNames()
Must return the qualified names of the attributes in context objects attribute list, in order, and a new list otherwise.
function getElementsByTagName
HTMLCollection getElementsByTagName(
DOMString qualifiedName
)
Returns the list of elements with qualified name qualifiedName for context object.
function getElementsByTagNameNS
HTMLCollection getElementsByTagNameNS(
DOMString? namespace,
DOMString localName
)
Return the list of elements with namespace namespace and local name localName for.
function getElementsByClassName
HTMLCollection getElementsByClassName(
DOMString classNames
)
Return the list of elements with class names classNames for context object.
function insertAdjacentElement
Element insertAdjacentElement(
DOMString where,
Element element
)
Inserts a given element node at a given position relative to the element it is invoked upon.
function insertAdjacentText
void insertAdjacentText(
DOMString where,
DOMString data
)
Inserts a given text node at a given position relative to the element it is invoked upon.
function closest
Element closest(
DOMString selectors
)
Returns the closest ancestor of the current element (or the current element itself) which matches the selectors given in parameter. If there isn’t such an ancestor, it returns null.
function matches
boolean matches(
DOMString selectors
)
Returns true if the element would be selected by the specified selector string; otherwise, returns false.
function blur
void blur()
Removes keyboard focus from this element.
function focus
void focus()
Gives keyboard focus to this element.
function insertAdjacentHTML
void insertAdjacentHTML(
DOMString position,
DOMString text
)
Parses the specified text as HTML or XML and inserts the resulting nodes into the DOM tree at a specified position.
function querySelector
Element querySelector(
DOMString selectors
)
Returns the first element that is a descendant of the element on which it is invoked that matches the specified group of selectors.
function querySelectorAll
NodeList querySelectorAll(
DOMString selectors
)
Returns a static (not live) NodeList of all elements descended from the element on which it is invoked that matches the specified group of CSS selectors. (The base element itself is not included, even if it matches.)
function getAnimations
sequence< Animation > getAnimations(
optional GetAnimationsOptions options
)
Returns an array of all the Animation objects that the element has.
Parameters:
- options options for Animations retrieval
function getBoundingClientRect
DOMRect getBoundingClientRect()
Returns the bounding rectangle of the element.
function getClientRects
DOMRectList getClientRects()
Returns a collection of the bounding rectangles for each CSS border box in the element.
function remove
void remove()
Removes node Note: This should be part of the ChildNode interface.
Public Attributes Documentation
variable tagName
readonly attribute DOMString tagName;
the element tag
variable prefix
readonly attribute DOMString prefix;
Returns the namespace prefix of the specified element, or null if no prefix is specified.
variable namespaceURI
readonly attribute DOMString namespaceURI;
Returns the namespace URI of the element, or null if the element is not in a namespace.
variable localName
readonly attribute DOMString localName;
returns the local part of the qualified name of an element.
variable slot
attribute DOMString slot;
Returns the name of the shadow DOM slot attached to the element. A slot is a placeholder inside a web component that users can fill with their own markup.
variable id
attribute DOMString id;
the id of the element
variable clientTop
readonly attribute long clientTop;
Returns the unscaled width of the top border of the element in pixels, ignoring any transforms.
variable clientLeft
readonly attribute long clientLeft;
Returns the unscaled width of the left border of the element in pixels, ignoring any transforms.
variable clientWidth
readonly attribute long clientWidth;
Returns the unscaled width of the padding box of the element, ignoring any transforms.
variable clientHeight
readonly attribute long clientHeight;
Returns the unscaled height of the padding box of the element, ignoring any transforms.
variable attributes
readonly attribute NamedNodeMap attributes;
Gets a list of all attributes for the Element.
variable children
readonly attribute NodeList children;
A collection rooted at context object matching only element children. Note: This should be part of the ParentNode interface, which Element implements. Note: The return type should be HTMLCollection.
variable firstElementChild
readonly attribute Element firstElementChild;
attributes getter must return the first child that is an element, and null otherwise. Note: This should be part of the ParentNode interface, which Element
variable lastElementChild
readonly attribute Element lastElementChild;
attributes getter must return the last child that is an element, and null otherwise. Note: This should be part of the ParentNode interface, which Element
variable previousElementSibling
readonly attribute Element previousElementSibling;
Returns the Element immediately prior to this node in its parent’s children list, or null if there is no Element in the list prior to this node. Note: This attribute is part of the NonDocumentTypeChildNode interface, which Element implements.
variable nextElementSibling
readonly attribute Element nextElementSibling;
Returns the Element immediately following this node in its parent’s children list, or null if there is no Element in the list following this node. Note: This attribute is part of the NonDocumentTypeChildNode interface, which Element implements.
variable childElementCount
readonly attribute unsigned long childElementCount;
attributes getter must return the number of children of context object that are elements. Note: This should be part of the ParentNode interface, which Element
variable scrollLeft
attribute float scrollLeft;
position of the horizontal scrollbar of the element
variable scrollLeftVW
attribute float scrollLeftVW;
scrollLeft in VW units The setter converts a given value into PX units based on viewport size
variable scrollLeftVH
attribute float scrollLeftVH;
scrollLeft in VH units The setter converts a given value into PX units based on viewport size
variable scrollTop
attribute float scrollTop;
position of the vertical scrollbar of the element
variable scrollTopVW
attribute float scrollTopVW;
scrollTop in VW units The setter converts a given value into PX units based on viewport size
variable scrollTopVH
attribute float scrollTopVH;
scrollTop in VH units The setter converts a given value into PX units based on viewport size
variable scrollWidth
readonly attribute long scrollWidth;
size of the horizontal scrollbar of the element
variable scrollWidthVW
readonly attribute long scrollWidthVW;
scrollWidth converted to VW units
variable scrollWidthVH
readonly attribute long scrollWidthVH;
scrollWidth converted to VH units
variable scrollHeight
readonly attribute long scrollHeight;
size of the vertical scrollbar of the element
variable scrollHeightVW
readonly attribute long scrollHeightVW;
scrollHeight converted to VH units
variable scrollHeightVH
readonly attribute long scrollHeightVH;
scrollHeight converted to VH units
variable className
attribute DOMString className;
all of the classes of the element
variable classList
readonly attribute DOMTokenList classList;
variable innerHTML
attribute DOMString innerHTML;
Gets or sets the contents of the element as HTML.
variable outerHTML
attribute DOMString outerHTML;
Gets a fragment of HTML or XML that represents the element and its contents.
variable focusin
attribute EventSetter focusin;
variable focusout
attribute EventSetter focusout;
variable abort
attribute EventSetter abort;
variable blur
attribute EventSetter blur;
variable click
attribute EventSetter click;
variable auxclick
attribute EventSetter auxclick;
variable dblclick
attribute EventSetter dblclick;
variable error
attribute EventSetter error;
variable focus
attribute EventSetter focus;
variable keydown
attribute EventSetter keydown;
variable keypress
attribute EventSetter keypress;
variable keyup
attribute EventSetter keyup;
variable load
attribute EventSetter load;
variable mousedown
attribute EventSetter mousedown;
variable mouseover
attribute EventSetter mouseover;
variable mouseout
attribute EventSetter mouseout;
variable mouseenter
attribute EventSetter mouseenter;
variable mouseleave
attribute EventSetter mouseleave;
variable mousemove
attribute EventSetter mousemove;
variable mouseup
attribute EventSetter mouseup;
variable input
attribute EventSetter input;
variable change
attribute EventSetter change;
variable scroll
attribute EventSetter scroll;
variable wheel
attribute EventSetter wheel;
variable touchstart
attribute EventSetter touchstart;
variable touchend
attribute EventSetter touchend;
variable touchmove
attribute EventSetter touchmove;
variable animationstart
attribute EventSetter animationstart;
variable animationend
attribute EventSetter animationend;
variable animationcancel
attribute EventSetter animationcancel;
variable animationiteration
attribute EventSetter animationiteration;
variable transitionstart
attribute EventSetter transitionstart;
variable transitionend
attribute EventSetter transitionend;
variable transitioncancel
attribute EventSetter transitioncancel;
variable transitionrun
attribute EventSetter transitionrun;