JavaScripture
Contribute via GitHub Feedback

JavaScript Element : Node

Element represents an element in the DOM/document tree. Element is the base type for HTMLElement and SVGElement.

Instance Properties

attributes : Array<Attr>

childElementCount : Number

Returns the number of direct children of this.

children : HTMLCollection

classList : DOMTokenList

className : String

Gets or sets the class name of the Element. className corresponds to the HTML class attribute. See also classList.

Example:

Run

Results:

 

clientHeight : Number  
clientLeft : Number  
clientTop : Number  
clientWidth : Number  
dataset : DOMStringMap  

Map of custom 'data-' prefixed attributes on this. Attribute names are converted to camel case.

Example:

Run

Results:

 

firstElementChild : Element

id : String

lastElementChild : Element

localName : String

namespaceURI : String

nextElementSibling : Element

prefix : String

previousElementSibling : Element

scrollHeight : Number  
scrollLeft : Number
scrollTop : Number
scrollWidth : Number  
shadowRoot : ShadowRoot  

tagName : String  

Instance Methods

createShadowRoot() : ShadowRoot
getAttribute(name : String) : String

getAttributeNS(namespaceURI : String, localName : String) : String

getBoundingClientRect() : ClientRect

Returns the rectangular bounds of this relative to the viewport. If this is a text element that is split on multiple lines, the rectangle will be enlarged to contain all portions. Use getClientRects() to get the rectangles of each portion.

Example:

Run

Results:

 

getClientRects() : ClientRectList

Returns a list of rectangles where this is in the document. This method is similar to getBoundingClientRect() except it will return a ClientRect for each part of the element (eg, text elements split on multiple lines will return a list with length > 1).

Example:

Run

Results:

 

getDestinationInsertionPoints() : NodeList
getElementsByClassName(classNames : String) : NodeList

Returns a list of descendants of this that match the specified class name. See also getElementsByTagName(), querySelector(), and querySelectorAll().

Example:

Run

Results:

 

getElementsByTagName(name : String) : NodeList

Returns a list of descendants of this that match the specified tag name. See also getElementsByTagNameNS(), getElementsByClassName(), querySelector(), and querySelectorAll().

Example:

Run

Results:

 

getElementsByTagNameNS(namespaceURI : String, localName : String) : NodeList

hasAttribute(name : String) : Boolean

hasAttributeNS(namespaceURI : String, localName : String) : Boolean

hasAttributes() : Boolean

querySelector(selector : String) : Element

Returns the first Element that matches the CSS selector. See also querySelectorAll(), getElementsByTagName(), and getElementsByClassName().

Example:

Run

Results:

 

querySelectorAll(cssSelector : String) : NodeList

Returns a NodeList containing the Elements in the document that match the CSS selector. See also querySelector(), getElementsByTagName(), and getElementsByClassName().

Example:

Run

Results:

 

removeAttribute(name : String) : undefined

removeAttributeNS(namespaceURI : String, localName : String) : undefined

scrollIntoView([top = false : Boolean]) : undefined

Scolls the element into view.

Example:

Run

Results:

 

setAttribute(name : String, value : String) : undefined

setAttributeNS(namespaceURI : String, qualifiedName : String, value : String) : undefined