@@ -3,32 +3,32 @@ querySelector - for single
33querySelectorAll - for multiple
44*/
55
6- const listItem = document . querySelector ( '#listItem' ) ;
7- // change background ul
8- listItem . style . background = '#333' ;
9- listItem . style . color = '#ddd' ;
6+ // querySelector
7+ const memberShp = document . querySelector ( '#shp' ) ;
8+ console . log ( memberShp ) ; //not node list output show element id shp
9+ // so u can add background without index
10+ memberShp . style . background = '#333' ;
11+ memberShp . style . width = '16rem' ;
1012
11- // if only querySelector, show just first
12- let shp = document . querySelector ( '.shp' ) ;
13- console . log ( shp ) ; //lutfy
14- // if use querySelectorAll
15- shp = document . querySelectorAll ( '.shp' ) ;
16- console . log ( shp ) ; //show node-list all
13+ //querySelectorAll
14+ const allMember = document . querySelectorAll ( '#shp' ) ;
15+ // check use log if node-list use index
16+ console . log ( allMember ) ; //here is node-list
1717
18- // SHP
19- const shpObject = [ ... shp ] ;
20- shpObject . forEach ( function ( items ) {
18+ const allMembers = [ ... allMember ] ;
19+ allMembers . forEach ( function ( items ) {
20+ items . style . color = '#fff' ;
2121 items . style . textTransform = 'uppercase' ;
22- items . style . fontSize = '1.25rem ' ;
22+ items . style . padding = '2rem ' ;
2323} ) ;
2424
25- // RHP
26- const rhp = document . querySelectorAll ( '.rhp' ) ;
27- const rhpObject = [ ...rhp ] ;
28- rhpObject . forEach ( function ( items ) {
29- items . style . textTransform = 'Capitalize' ;
30- items . style . fontSize = '1.25rem' ;
31- } ) ;
25+ // here u should use querySelector, so why?
26+ // because only querySelector only acces for first
27+ // change first-child be red background and actuallly
28+ // u can write without first-child if want change lutfy be red
29+ const beRed = document . querySelector ( 'li' ) ;
30+ beRed . style . background = 'coral' ;
3231
33- const memberRHP = document . querySelector ( 'li:last-child' ) ;
34- console . log ( memberRHP ) ;
32+ // and last-child be blue
33+ const beBlue = document . querySelector ( 'li:last-child' ) ;
34+ beBlue . style . background = 'blue' ;
0 commit comments