mirror of
https://github.com/bendtherules/UiQuestions.git
synced 2026-08-18 22:02:42 +00:00
create-modify-element - clarify method name
This commit is contained in:
@@ -64,7 +64,7 @@ for (var p of paras) {
|
|||||||
|
|
||||||
### 1. `createElement()`
|
### 1. `createElement()`
|
||||||
|
|
||||||
The `document.createElement` method creates a new HTML element, taking the tag name (`"div"`) as first argument.
|
It creates a new HTML element, taking the tag name (`"div"`) as argument.
|
||||||
|
|
||||||
To set attributes and add the element to DOM, look at `.setAttribute` and `.appendChild` below.
|
To set attributes and add the element to DOM, look at `.setAttribute` and `.appendChild` below.
|
||||||
|
|
||||||
@@ -92,7 +92,7 @@ document.createElement("div")
|
|||||||
|
|
||||||
### 2. `setAttribute()`
|
### 2. `setAttribute()`
|
||||||
|
|
||||||
Every element has a `setAttribute` method - which sets a attribute on the current element.
|
`Element.setAttribute` sets a attribute on the current element.
|
||||||
|
|
||||||
`setAttribute(name, value)`
|
`setAttribute(name, value)`
|
||||||
|
|
||||||
@@ -110,7 +110,7 @@ ele.setAttribute("type", "text")
|
|||||||
|
|
||||||
### 3. `appendChild()`
|
### 3. `appendChild()`
|
||||||
|
|
||||||
The `.appendChild()` method inserts a new element as the last child of the current element.
|
`Element.appendChild` inserts a new element as the last child of the current element.
|
||||||
|
|
||||||
`ele1.appendChild(ele2)`
|
`ele1.appendChild(ele2)`
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user