Hi there! Are you looking for the official Deno documentation? Try docs.deno.com for all your Deno learning needs.

Element

Element is the most general base class from which all objects in a Document inherit. It only has methods and properties common to all kinds of elements. More specific classes inherit from Element.

interface Element extends Node, ARIAMixin, Animatable, ChildNode, InnerHTML, NonDocumentTypeChildNode, ParentNode, Slottable {
readonly attributes: NamedNodeMap;
readonly classList: DOMTokenList;
className: string;
readonly clientHeight: number;
readonly clientLeft: number;
readonly clientTop: number;
readonly clientWidth: number;
id: string;
readonly localName: string;
readonly namespaceURI: string | null;
onfullscreenchange: ((this: Element, ev: Event) => any) | null;
onfullscreenerror: ((this: Element, ev: Event) => any) | null;
outerHTML: string;
readonly ownerDocument: Document;
readonly part: DOMTokenList;
readonly prefix: string | null;
readonly scrollHeight: number;
scrollLeft: number;
scrollTop: number;
readonly scrollWidth: number;
readonly shadowRoot: ShadowRoot | null;
slot: string;
readonly tagName: string;
addEventListener<K extends keyof ElementEventMap>(
type: K,
listener: (this: Element, ev: ElementEventMap[K]) => any,
options?: boolean | AddEventListenerOptions,
): void;
addEventListener(
type: string,
options?: boolean | AddEventListenerOptions,
): void;
attachShadow(init: ShadowRootInit): ShadowRoot;
closest<K extends keyof HTMLElementTagNameMap>(selector: K): HTMLElementTagNameMap[K] | null;
closest<K extends keyof SVGElementTagNameMap>(selector: K): SVGElementTagNameMap[K] | null;
closest<E extends Element = Element>(selectors: string): E | null;
getAttribute(qualifiedName: string): string | null;
getAttributeNames(): string[];
getAttributeNode(qualifiedName: string): Attr | null;
getAttributeNodeNS(namespace: string | null, localName: string): Attr | null;
getAttributeNS(namespace: string | null, localName: string): string | null;
getBoundingClientRect(): DOMRect;
getClientRects(): DOMRectList;
getElementsByClassName(classNames: string): HTMLCollectionOf<Element>;
getElementsByTagName<K extends keyof HTMLElementTagNameMap>(qualifiedName: K): HTMLCollectionOf<HTMLElementTagNameMap[K]>;
getElementsByTagName<K extends keyof SVGElementTagNameMap>(qualifiedName: K): HTMLCollectionOf<SVGElementTagNameMap[K]>;
getElementsByTagName(qualifiedName: string): HTMLCollectionOf<Element>;
getElementsByTagNameNS(namespaceURI: "http://www.w3.org/1999/xhtml", localName: string): HTMLCollectionOf<HTMLElement>;
getElementsByTagNameNS(namespaceURI: "http://www.w3.org/2000/svg", localName: string): HTMLCollectionOf<SVGElement>;
getElementsByTagNameNS(namespace: string | null, localName: string): HTMLCollectionOf<Element>;
hasAttribute(qualifiedName: string): boolean;
hasAttributeNS(namespace: string | null, localName: string): boolean;
hasAttributes(): boolean;
hasPointerCapture(pointerId: number): boolean;
insertAdjacentElement(where: InsertPosition, element: Element): Element | null;
insertAdjacentHTML(position: InsertPosition, text: string): void;
insertAdjacentText(where: InsertPosition, data: string): void;
matches(selectors: string): boolean;
releasePointerCapture(pointerId: number): void;
removeAttribute(qualifiedName: string): void;
removeAttributeNode(attr: Attr): Attr;
removeAttributeNS(namespace: string | null, localName: string): void;
removeEventListener<K extends keyof ElementEventMap>(
type: K,
listener: (this: Element, ev: ElementEventMap[K]) => any,
options?: boolean | EventListenerOptions,
): void;
removeEventListener(
type: string,
options?: boolean | EventListenerOptions,
): void;
requestFullscreen(options?: FullscreenOptions): Promise<void>;
requestPointerLock(): void;
scroll(options?: ScrollToOptions): void;
scroll(x: number, y: number): void;
scrollBy(options?: ScrollToOptions): void;
scrollBy(x: number, y: number): void;
scrollIntoView(arg?: boolean | ScrollIntoViewOptions): void;
scrollTo(options?: ScrollToOptions): void;
scrollTo(x: number, y: number): void;
setAttribute(qualifiedName: string, value: string): void;
setAttributeNode(attr: Attr): Attr | null;
setAttributeNodeNS(attr: Attr): Attr | null;
setAttributeNS(
namespace: string | null,
qualifiedName: string,
value: string,
): void;
setPointerCapture(pointerId: number): void;
toggleAttribute(qualifiedName: string, force?: boolean): boolean;
webkitMatchesSelector(selectors: string): boolean;
}
var Element: {
prototype: Element;
new (): Element;
}
;

§Extends

§Properties

§
readonly attributes: NamedNodeMap
[src]
§
readonly classList: DOMTokenList
[src]

Allows for manipulation of element's class content attribute as a set of whitespace-separated tokens through a DOMTokenList object.

§
className: string
[src]

Returns the value of element's class content attribute. Can be set to change it.

§
readonly clientHeight: number
[src]
§
readonly clientLeft: number
[src]
§
readonly clientTop: number
[src]
§
readonly clientWidth: number
[src]
§
id: string
[src]

Returns the value of element's id content attribute. Can be set to change it.

§
readonly localName: string
[src]

Returns the local name.

§
readonly namespaceURI: string | null
[src]

Returns the namespace.

§
onfullscreenchange: ((this: Element, ev: Event) => any) | null
[src]
§
onfullscreenerror: ((this: Element, ev: Event) => any) | null
[src]
§
outerHTML: string
[src]
§
readonly ownerDocument: Document
[src]
§
readonly part: DOMTokenList
[src]
§
readonly prefix: string | null
[src]

Returns the namespace prefix.

§
readonly scrollHeight: number
[src]
§
scrollLeft: number
[src]
§
scrollTop: number
[src]
§
readonly scrollWidth: number
[src]
§
readonly shadowRoot: ShadowRoot | null
[src]

Returns element's shadow root, if any, and if shadow root's mode is "open", and null otherwise.

§
slot: string
[src]

Returns the value of element's slot content attribute. Can be set to change it.

§
readonly tagName: string
[src]

Returns the HTML-uppercased qualified name.

§Methods

§
addEventListener<K extends keyof ElementEventMap>(
type: K,
listener: (this: Element, ev: ElementEventMap[K]) => any,
options?: boolean | AddEventListenerOptions,
): void
[src]
§
addEventListener(
type: string,
options?: boolean | AddEventListenerOptions,
): void
[src]
§
attachShadow(init: ShadowRootInit): ShadowRoot
[src]

Creates a shadow root for element and returns it.

§
closest<K extends keyof HTMLElementTagNameMap>(selector: K): HTMLElementTagNameMap[K] | null
[src]

Returns the first (starting at element) inclusive ancestor that matches selectors, and null otherwise.

§
closest<K extends keyof SVGElementTagNameMap>(selector: K): SVGElementTagNameMap[K] | null
[src]
§
closest<E extends Element = Element>(selectors: string): E | null
[src]
§
getAttribute(qualifiedName: string): string | null
[src]

Returns element's first attribute whose qualified name is qualifiedName, and null if there is no such attribute otherwise.

§
getAttributeNames(): string[]
[src]

Returns the qualified names of all element's attributes. Can contain duplicates.

§
getAttributeNode(qualifiedName: string): Attr | null
[src]
§
getAttributeNodeNS(namespace: string | null, localName: string): Attr | null
[src]
§
getAttributeNS(namespace: string | null, localName: string): string | null
[src]

Returns element's attribute whose namespace is namespace and local name is localName, and null if there is no such attribute otherwise.

§
getBoundingClientRect(): DOMRect
[src]
§
getClientRects(): DOMRectList
[src]
§
getElementsByClassName(classNames: string): HTMLCollectionOf<Element>
[src]

Returns a HTMLCollection of the elements in the object on which the method was invoked (a document or an element) that have all the classes given by classNames. The classNames argument is interpreted as a space-separated list of classes.

§
getElementsByTagName<K extends keyof HTMLElementTagNameMap>(qualifiedName: K): HTMLCollectionOf<HTMLElementTagNameMap[K]>
[src]
§
getElementsByTagName<K extends keyof SVGElementTagNameMap>(qualifiedName: K): HTMLCollectionOf<SVGElementTagNameMap[K]>
[src]
§
getElementsByTagName(qualifiedName: string): HTMLCollectionOf<Element>
[src]
§
getElementsByTagNameNS(namespaceURI: "http://www.w3.org/1999/xhtml", localName: string): HTMLCollectionOf<HTMLElement>
[src]
§
getElementsByTagNameNS(namespaceURI: "http://www.w3.org/2000/svg", localName: string): HTMLCollectionOf<SVGElement>
[src]
§
getElementsByTagNameNS(namespace: string | null, localName: string): HTMLCollectionOf<Element>
[src]
§
hasAttribute(qualifiedName: string): boolean
[src]

Returns true if element has an attribute whose qualified name is qualifiedName, and false otherwise.

§
hasAttributeNS(namespace: string | null, localName: string): boolean
[src]

Returns true if element has an attribute whose namespace is namespace and local name is localName.

§
hasAttributes(): boolean
[src]

Returns true if element has attributes, and false otherwise.

§
hasPointerCapture(pointerId: number): boolean
[src]
§
insertAdjacentElement(where: InsertPosition, element: Element): Element | null
[src]
§
insertAdjacentHTML(position: InsertPosition, text: string): void
[src]
§
insertAdjacentText(where: InsertPosition, data: string): void
[src]
§
matches(selectors: string): boolean
[src]

Returns true if matching selectors against element's root yields element, and false otherwise.

§
releasePointerCapture(pointerId: number): void
[src]
§
removeAttribute(qualifiedName: string): void
[src]

Removes element's first attribute whose qualified name is qualifiedName.

§
removeAttributeNode(attr: Attr): Attr
[src]
§
removeAttributeNS(namespace: string | null, localName: string): void
[src]

Removes element's attribute whose namespace is namespace and local name is localName.

§
removeEventListener<K extends keyof ElementEventMap>(
type: K,
listener: (this: Element, ev: ElementEventMap[K]) => any,
options?: boolean | EventListenerOptions,
): void
[src]
§
removeEventListener(
type: string,
options?: boolean | EventListenerOptions,
): void
[src]
§
requestFullscreen(options?: FullscreenOptions): Promise<void>
[src]

Displays element fullscreen and resolves promise when done.

When supplied, options's navigationUI member indicates whether showing navigation UI while in fullscreen is preferred or not. If set to "show", navigation simplicity is preferred over screen space, and if set to "hide", more screen space is preferred. User agents are always free to honor user preference over the application's. The default value "auto" indicates no application preference.

§
requestPointerLock(): void
[src]
§
scroll(options?: ScrollToOptions): void
[src]
§
scroll(x: number, y: number): void
[src]
§
scrollBy(options?: ScrollToOptions): void
[src]
§
scrollBy(x: number, y: number): void
[src]
§
scrollIntoView(arg?: boolean | ScrollIntoViewOptions): void
[src]
§
scrollTo(options?: ScrollToOptions): void
[src]
§
scrollTo(x: number, y: number): void
[src]
§
setAttribute(qualifiedName: string, value: string): void
[src]

Sets the value of element's first attribute whose qualified name is qualifiedName to value.

§
setAttributeNode(attr: Attr): Attr | null
[src]
§
setAttributeNodeNS(attr: Attr): Attr | null
[src]
§
setAttributeNS(
namespace: string | null,
qualifiedName: string,
value: string,
): void
[src]

Sets the value of element's attribute whose namespace is namespace and local name is localName to value.

§
setPointerCapture(pointerId: number): void
[src]
§
toggleAttribute(qualifiedName: string, force?: boolean): boolean
[src]

If force is not given, "toggles" qualifiedName, removing it if it is present and adding it if it is not present. If force is true, adds qualifiedName. If force is false, removes qualifiedName.

Returns true if qualifiedName is now present, and false otherwise.

§
webkitMatchesSelector(selectors: string): boolean
[src]