DOM Node State

Selectors allow you to get a server-side representation of a DOM node's state. This representation exposes API that is similar to DOM objects.

See how to obtain element state in the Obtain Element State article.

Members Common Across All Nodes

Property Type Description
childElementCount Number The number of child HTML elements.
childNodeCount Number The number of child nodes.
hasChildElements Boolean true if this node has child HTML elements.
hasChildNodes Boolean true if this node has child nodes.
nodeType Number The type of the node. See Node.nodeType.
textContent String The text content of the node and its descendants. See Node.textContent.
Method Type Description
hasClass(className) Boolean true if the element has the specified class name.

Members Specific to Element Nodes

Property Type Description
attributes Object Attributes of the element as { name: value, ... }. You can also use the getAttribute method to access attribute values.
boundingClientRect Object The size of the element and its position relative to the viewport. Contains the left, right, bottom, top, width and height properties. You can also use the getBoundingClientRectProperty method to access these properties.
checked Boolean For checkbox and radio input elements, their current state. For other elements, undefined.
classNames Array of String The list of element's classes.
clientHeight Number The inner height of the element, including padding but not the horizontal scrollbar height, border, or margin. See Element.clientHeight.
clientLeft Number The width of the left border of the element. See Element.clientLeft.
clientTop Number The width of the top border of the element. See Element.clientTop.
clientWidth Number The inner width of the element, including padding but not the vertical scrollbar width, border, or margin. See Element.clientWidth.
focused Boolean true if the element is focused.
id String The element's identifier. See Element.id.
innerText String The element's text content "as rendered". See The innerText IDL attribute.
namespaceURI String The namespace URI of the element. If the element does not have a namespace, this property is set to null. See Element.namespaceURI.
offsetHeight Number The height of the element including vertical padding and borders. See HTMLElement.offsetHeight.
offsetLeft Number The number of pixels that the upper left corner of the element is offset by to the left within the offsetParent node. See HTMLElement.offsetLeft.
offsetTop Number The number of pixels that the upper left corner of the element is offset by to the top within the offsetParent node. See HTMLElement.offsetTop.
offsetWidth Number The width of the element including vertical padding and borders. See HTMLElement.offsetWidth.
selected Boolean Indicates that <option> element is currently selected. For other elements, undefined. See HTMLOptionElement.
selectedIndex Number For <select> element, the index of the first selected <option> element. For other elements, undefined. See HTMLSelectElement.selectedIndex.
scrollHeight Number The height of the element's content, including content not visible on the screen due to overflow. See Element.scrollHeight.
scrollLeft Number The number of pixels that the element's content is scrolled to the left. See Element.scrollLeft.
scrollTop Number The number of pixels that the element's content is scrolled upward. See Element.scrollTop.
scrollWidth Number Either the width in pixels of the element's content or the width of the element itself, whichever is greater. See Element.scrollWidth.
style Object The computed values of element's CSS properties as { property: value, ... }. You can also use the getStyleProperty method to access CSS properties.
tagName String The name of the element. See Element.tagName.
value String For input elements, the current value in the control. For other elements, undefined.
visible Boolean true if the element is visible.
Method Type Description
getStyleProperty(propertyName) Object Returns the computed value of the CSS propertyName property. You can also use the style property to access a hash table of CSS properties.
getAttribute(attributeName) String Returns the value of the attributeName attribute. You can also use the attributes property to access a hash table of attributes.
getBoundingClientRectProperty(propertyName) Number Returns the value of the propertyName property from the boundingClientRect object.