File tree Expand file tree Collapse file tree 2 files changed +19
-8
lines changed Expand file tree Collapse file tree 2 files changed +19
-8
lines changed Original file line number Diff line number Diff line change 33// remember this element not read white space just element
44// and not same with nextSibling read white space, read comment
55
6- const result = document . querySelector ( '#result' ) ;
7- console . log ( result . previousElementSibling ) ; //hohoho
6+ const list_items = document . querySelector ( 'ul' ) ;
7+ // previousElementSibling
8+ list_items . previousElementSibling . style . background = 'blue' ;
9+ // nextElementSibling ul > next or inside ul
10+ // output <script src=........
11+ const nextLi = list_items . nextElementSibling ;
12+ console . log ( nextLi ) ;
813
9- const last = document . querySelector ( '#last' ) ;
10- const modification = last . previousElementSibling ;
11- modification . style . fontSize = '2rem' ;
12- modification . style . textTransform = 'uppercase' ;
14+ const headingNext = document . querySelector ( 'h2' ) ;
15+ // nextElement is ul and add background ul be red
16+ headingNext . nextElementSibling . style . background = 'red' ;
Original file line number Diff line number Diff line change @@ -69,12 +69,19 @@ <h2>SHP Pirates</h2>
6969 </ul>
7070 </div> -->
7171
72- <!-- nextSibling & previousSibling -->
72+ <!-- nextSibling & previousSibling
7373 <div class="container">
7474 <h3>sub title</h3>
7575 <h2>main title</h2>
76- </ div >
76+ </div> -->
7777
78+ <!-- nextElementSibling & previousElementSibling -->
79+ < h2 > The Pirates</ h2 >
80+ < ul id ="list-item ">
81+ < li class ="lutfy "> shp</ li >
82+ < li > rhp</ li >
83+ < li > marine ford</ li >
84+ </ ul >
7885 <!-- source js -->
7986 <!-- <script src="/01_getElementById.js"></script> -->
8087 <!-- <script src="/02_getElementByTagName.js"></script> -->
You can’t perform that action at this time.
0 commit comments