Create a button:
The result will be:
HTML elements often contains text. To create a button with text you must also create a Text Node which you append to the button element:
Create a button with text:
The result will be:
The createElement() method creates an Element Node with the specified name.
Read more about the Element Node object in our Element Node object reference.
![]()
The createElement() method is supported in all major browsers.
| Parameter | Type | Description |
|---|---|---|
| nodename | String | Required. The name of the element you want to create |
| Type | Description |
|---|---|
| Element object | The created Element node |
| DOM Version | Core Level 1 |
|---|
Your message has been sent to W3Schools.