Easy Tutorial
❮ Prop Radio Defaultchecked Prop Canvas Font ❯

HTML DOM createElement() Method

Document Object

Example

Create a button:

Output result:


HTML elements often contain text. To create a button with specified text, you need to add a text node after the button element:

Example

Create a button with specified text:

Output result:


Definition and Usage

The createElement() method creates an element with the specified name.


Browser Support

All major browsers support the createElement() method.


Syntax

Parameters

Parameter Type Description
nodename String Required. The name of the element to create.

Return Value

Type Description
Element Object The created element node.

Technical Details

| DOM Version | Core Level 1 Document Object | | --- | --- |


Document Object

❮ Prop Radio Defaultchecked Prop Canvas Font ❯