Represents a DOM element matched by a Selection, and provides an API to inspect the element content.
Use Selection.get(index) to return an Element object.
The Element object provides a similar API to the DOM Element API to retrieve element information.
Method | Description |
---|---|
nodeName | The name of the element. |
nodeType | The type of the element. |
nodeValue | The element value. |
id | The id of the element. |
innerHTML | Is a DOMString representing the markup of the element's content. |
textContent | The element content. |
ownerDocument | Element |
attributes | An array of attributes. |
firstChild | Element |
lastChild | Element |
childElementCount | The number of children elements. |
firstElementChild | Element |
lastElementChild | Element |
previousSibling | Element |
nextSibling | Element |
previousElementSibling | Element |
nextElementSibling | Element |
parentElement | Element |
parentNode | Element |
childNodes | Array of Element |
children | Array of Element |
classList | An array of class names. |
className | The class name string |
lang | The value of the lang attribute. |
toString | The element string representation. |
hasAttribute | Boolean |
getAttribute | getAttributeNode |
hasAttributes | Boolean |
hasChildNodes | Boolean |
isSameNode | Boolean |
isEqualNode | Boolean |
getElementsByClassName | Return an array of Element. |
getElementsByTagName | Return an array of Element. |
querySelector | Returns the first Element which matches the specified selector string relative to the element |
querySelectorAll | Returns all the Element which matches the specified selector string relative to the element |
contains | |
matches | Returns a Boolean indicating whether or not the element would be selected by the specified selector string |
namespaceURI | The namespace URI of the element. |
isDefaultNamespace | Returns a Boolean indicating whether the element has the default namespace. |
Additionally, Element can provide more methods depending on the Element type.
AnchorElement: hash, host, hostname, port, username, password, origin, pathname, protocol, relist, search, text.
ButtonElement: form, formAction, formEnctype, formMethod, formNoValidate, formTarget, labels, name, value.
CanvasElement: width, height
DataListElement: options
FieldSetElement: elements, type, form
FormElement: elements, length, method
InputElement: form
LabelElement: control, form
LegendElement: form
LinkElement: relList
MapElement: areas, images
ObjectElement: form
OptionElement: disabled, form, index, label, text, value
OutputElement: value, labels
ProgressElement: max, value, position
ScriptElement: text
SelectElement: form, length, options, selectedOptions, selectedIndex, value
StyleElement: text
TableElement: caption, thead, tbody, tfoot, rows
TableCellElement: cellIndex, colSpan, rowSpan, headers
TableRowElement: cells, colSpan, sectionRowIndex, rowIndex
VideoElement: textTracks
TitleElement: text