Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/deno_dom/src/dom/element.ts>Element

Browser DOM & HTML parser in Deno
Extremely Popular
Latest
class Element
extends Node
import { Element } from "https://deno.land/x/deno_dom@v0.1.48/src/dom/element.ts";

Constructors

new
Element(
tagName: string,
parentNode: Node | null,
attributes: [string, string][],
key: CTOR_KEY,
)

Properties

attributes: NamedNodeMap
readonly
childElementCount: number
readonly
children: HTMLCollection
readonly
classList: DOMTokenList
className: string
readonly
dataset: Record<string, string | undefined>
readonly
firstElementChild: Element | null
id: string
innerHTML: string
innerText: string
readonly
lastElementChild: Element | null
localName: string
readonly
nextElementSibling: Element | null
outerHTML: string
readonly
previousElementSibling: Element | null

Methods

_getElementsByTagName(tagName: string, search: Node[]): Node[]
after(...nodes: (Node | string)[])
append(...nodes: (Node | string)[])
before(...nodes: (Node | string)[])
closest(selectorString: string): Element | null
getAttribute(name: string): string | null
getAttributeNames(): string[]
getElementById(id: string): Element | null
getElementsByClassName(className: string): Element[]
getElementsByTagName(tagName: string): Element[]
getElementsByTagNameNS(_namespace: string, localName: string): Element[]
hasAttribute(name: string): boolean
hasAttributeNS(_namespace: string, name: string): boolean
matches(selectorString: string): boolean
prepend(...nodes: (Node | string)[])
querySelector<T = Element>(selectors: string): T | null
querySelectorAll<T extends Element = Element>(selectors: string): NodeList<T>
removeAttribute(rawName: string)
replaceWith(...nodes: (Node | string)[])
setAttribute(rawName: string, value: any)
toggleAttribute(rawName: string, force?: boolean): boolean