@@ -6,8 +6,6 @@ Here we'll see how to create new elements "on the fly" and modify the existing p
6
6
7
7
First we'll see a simple example and then explain the methods.
8
8
9
- [ cut]
10
-
11
9
## Example: show a message
12
10
13
11
For a start, let's see how to add a message on the page that looks nicer than ` alert ` .
@@ -32,7 +30,7 @@ Here's how it will look:
32
30
*/!*
33
31
```
34
32
35
- That was an HTML example. Now let's create the same ` div ` with JavaScript (assuming that the styles are still in the HTML or an external CSS).
33
+ That was an HTML example. Now let's create the same ` div ` with JavaScript (assuming that the styles are still in the HTML or an external CSS file ).
36
34
37
35
## Creating an element
38
36
@@ -63,7 +61,7 @@ div.className = "alert alert-success";
63
61
div .innerHTML = " <strong>Hi there!</strong> You've read an important message." ;
64
62
```
65
63
66
- After that, we have a ready DOM element. Right now it's in the variable, but can not be seen, because not inserted into the page yet.
64
+ After that, we have a ready DOM element. Right now it's in the variable, but can not be seen, because it's not been inserted into the page yet.
67
65
68
66
## Insertion methods
69
67
@@ -137,9 +135,8 @@ Here's a brief list of methods to insert a node into a parent element (`parentEl
137
135
*/!*
138
136
</script>
139
137
```
140
-
141
- To insert as the first element, we can do like this:
142
-
138
+ To insert `newLi` as the first element, we can do it like this:
139
+
143
140
```js
144
141
list.insertBefore(newLi, list.firstChild);
145
142
```
@@ -206,7 +203,7 @@ before
206
203
after
207
204
```
208
205
209
- These methods can insert multiple list of nodes and text pieces in a single call.
206
+ These methods can insert multiple lists of nodes and text pieces in a single call.
210
207
211
208
For instance, here a string and an element are inserted:
212
209
0 commit comments