Skip to content

Element

Unofficial

Augments the built-in Element interface.

Signature:

export interface Element extends Node

Extends: Node

Properties

PropertyTypeDescription
constructorWinWindowGlobal window object.
(Inherited from Node)
docDocumentThe document this node belongs to, or the global document.
(Inherited from Node)
winWindowThe window object this node belongs to, or the global window.
(Inherited from Node)

Methods

MethodReturnsDescription
addClass(classes?)voidAdds a class to the element.
addClasses(classes)voidAdds multiple classes to the element.
appendText(val)voidAppends a text node to the node.
(Inherited from Node)
createDiv(o?, callback?)HTMLDivElementCreates a new <div> element.
(Inherited from Node)
createEl(tag, o?, callback?)HTMLElementTagNameMap[K]Create an element and append it to this node.
(Inherited from Node)
createSpan(o?, callback?)HTMLSpanElementCreates a new <span> element.
(Inherited from Node)
createSvg(tag, o?, callback?)SVGElementTagNameMap[K]Creates a new svg element such as <svg>, <circle>, <rect>, etc.
(Inherited from Node)
detach()voidDetaches the node from the DOM.
(Inherited from Node)
empty()voidEmpties the node.
(Inherited from Node)
find(selector)Element | nullFinds the first descendant element that matches the selector.
findAll(selector)Element[]Finds all descendant elements that match the selector.
findAllSelf(selector)Element[]Finds all descendant elements or self that match the selector.
getAttr(qualifiedName)null | stringGets an attribute from the element.
getCssPropertyValue(property, pseudoElement?)stringGets the value of a CSS property of the element.
getText()stringReturns the text content of the element.
hasClass(cls)booleanChecks if the element has a class.
indexOf(other)numberReturns the index of the node or -1 if the node is not found.
(Inherited from Node)
insertAfter(node, child)TInserts a child node after the current node.
(Inherited from Node)
instanceOf(type)this is TCross-window capable instanceof check, a drop-in replacement for instanceof checks on DOM Nodes. Remember to also check for nulls when necessary.
(Inherited from Node)
isActiveElement()booleanChecks if the element is the active element.
matchParent(selector, lastParent?)Element | nullMatches the selector recursively up the DOM tree.
removeClass(classes?)voidRemoves a class from the element.
removeClasses(classes)voidRemoves multiple classes from the element.
setAttr(qualifiedName, value)voidSets an attribute on the element.
setAttrs(obj)voidSets multiple attributes on the element.
setChildrenInPlace(children)voidSets the children of the node.
(Inherited from Node)
setText(val)voidSets the text content of the element.
toggleClass(classes, value)voidToggles a class on the element.

Links to this page: