Skip to content

HTMLElement

Unofficial

Augments the built-in HTMLElement interface.

Signature:

export interface HTMLElement extends Element

Extends: Element

Properties

PropertyTypeDescription
_EVENTS?{
K in keyof [HTMLElementEventMap]?: EventListenerInfo[];
}
The event listeners of the element.
constructorWinWindowGlobal window object.
(Inherited from Element)
docDocumentThe document this node belongs to, or the global document.
(Inherited from Element)
innerHeightnumberGet the inner height of this element without padding.
innerWidthnumberGet the inner width of this element without padding.
winWindowThe window object this node belongs to, or the global window.
(Inherited from Element)

Methods

MethodReturnsDescription
addClass(classes?)voidAdds a class to the element.
(Inherited from Element)
addClasses(classes)voidAdds multiple classes to the element.
(Inherited from Element)
addEventListeners(listeners)voidAdds a listener for each event named in the given map.
appendText(val)voidAppends a text node to the node.
(Inherited from Element)
createDiv(o?, callback?)HTMLDivElementCreates a new <div> element.
(Inherited from Element)
createEl(tag, o?, callback?)HTMLElementTagNameMap[K]Create an element and append it to this node.
(Inherited from Element)
createSpan(o?, callback?)HTMLSpanElementCreates a new <span> element.
(Inherited from Element)
createSvg(tag, o?, callback?)SVGElementTagNameMap[K]Creates a new svg element such as <svg>, <circle>, <rect>, etc.
(Inherited from Element)
detach()voidDetaches the node from the DOM.
(Inherited from Element)
empty()voidEmpties the node.
(Inherited from Element)
find(selector)Element | nullFinds the first descendant element that matches the selector.
(Inherited from Element)
findAll(selector)Element[]Finds all descendant elements that match the selector.
(Inherited from Element)
findAllSelf(selector)Element[]Finds all descendant elements or self that match the selector.
(Inherited from Element)
getAttr(qualifiedName)null | stringGets an attribute from the element.
(Inherited from Element)
getCssPropertyValue(property, pseudoElement?)stringGets the value of a CSS property of the element.
(Inherited from Element)
getText()stringReturns the text content of the element.
(Inherited from Element)
hasClass(cls)booleanChecks if the element has a class.
(Inherited from Element)
hide()voidHides the element using css display property.
indexOf(other)numberReturns the index of the node or -1 if the node is not found.
(Inherited from Element)
insertAfter(node, child)TInserts a child node after the current node.
(Inherited from Element)
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 Element)
isActiveElement()booleanChecks if the element is the active element.
(Inherited from Element)
isShown()booleanReturns whether this element is shown, when the element is attached to the DOM and none of the parent and ancestor elements are hidden with display: none.

Exception: Does not work on <body> and <html>, or on elements with position: fixed.
matchParent(selector, lastParent?)Element | nullMatches the selector recursively up the DOM tree.
(Inherited from Element)
off(this, type, selector, listener, options?)voidRemoves an event listener from the element.
on(this, type, selector, listener, options?)voidAdds an event listener to the element.
onClickEvent(this, listener, options?)voidAdds a click event listener to the element.
onNodeInserted(this, listener, once?)() => voidAdds an event listener to the element when it is inserted into the DOM.
onWindowMigrated(this, listener)() => voidAdds an event listener to the element when it is migrated to another window.
removeClass(classes?)voidRemoves a class from the element.
(Inherited from Element)
removeClasses(classes)voidRemoves multiple classes from the element.
(Inherited from Element)
setAttr(qualifiedName, value)voidSets an attribute on the element.
(Inherited from Element)
setAttrs(obj)voidSets multiple attributes on the element.
(Inherited from Element)
setChildrenInPlace(children)voidSets the children of the node.
(Inherited from Element)
setCssProps(props)voidSets the CSS properties of the element.
setCssStyles(styles)voidSets the CSS styles of the element.
setText(val)voidSets the text content of the element.
(Inherited from Element)
show()voidShows the element using css display property.
toggle(show)voidToggles the visibility of the element using css display property.
toggleClass(classes, value)voidToggles a class on the element.
(Inherited from Element)
toggleVisibility(visible)voidToggles the visibility of the element using css visibility property.
trigger(eventType)voidTriggers an event on the element.

Links to this page: