Web APIs

CustomElementRegistry.prototype.define()

Try the free JavaScript compiler

Registers a valid custom element name and its constructor in the registry.

Formal Syntax & Structure

javascript syntaxjavascript
customElements.define(name, constructor)

Parameters & Attributes

NameTypeDescription
namestringValid custom element name.
constructorFunctionCustom element constructor.

Return Value

undefined

Registers a valid custom element name and its constructor in the registry.

Working Example

Example Snippetjavascript
(async () => {class LessonStatus extends HTMLElement{};customElements.define("lesson-status",LessonStatus);const el=document.createElement("lesson-status");console.log(el instanceof LessonStatus);})()
JavaScript Reference