File tree 2 files changed +20
-2
lines changed
2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change
1
+ // createElement('element)
2
+ // createTextNode('text content')
3
+ // element.appendChild(childElement)
4
+ // insertBefore('element','location') -> not child
5
+
6
+ const container = document . querySelector ( '.container' ) ;
7
+ const shp = document . querySelector ( '.shp' ) ;
8
+
9
+ // rhp
10
+ const rhp = document . createElement ( 'h2' ) ;
11
+ const title = document . createTextNode ( 'The Pirates of RHP' ) ;
12
+ rhp . appendChild ( title ) ;
13
+ rhp . classList . add ( 'blue' ) ;
14
+ shp . classList . add ( 'red' ) ;
15
+ // insertBefore
16
+ // rhp is element, and shp is location after rhp
17
+ container . insertBefore ( rhp , shp ) ;
Original file line number Diff line number Diff line change @@ -122,7 +122,7 @@ <h2 class="third">third element</h2> -->
122
122
123
123
<!-- createElement, createTextNode , appendChild -->
124
124
< div class ="container ">
125
- < h2 > The Pirates of SHP</ h2 >
125
+ < h2 class =" shp " > The Pirates of SHP</ h2 >
126
126
</ div >
127
127
<!-- source js -->
128
128
<!-- <script src="/01_getElementById.js"></script> -->
@@ -136,6 +136,7 @@ <h2>The Pirates of SHP</h2>
136
136
<!-- <script src="/09_textContent.js"></script> -->
137
137
<!-- <script src="/10_getAttribute.js"></script> -->
138
138
<!-- <script src="/11_className-classList.js"></script> -->
139
- < script src ="/12_createElement_textnode_appendChild.js "> </ script >
139
+ <!-- <script src="/12_createElement_textnode_appendChild.js"></script> -->
140
+ < script src ="/13_insertBefore.js "> </ script >
140
141
</ body >
141
142
</ html >
You can’t perform that action at this time.
0 commit comments