FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
JavaScript-DOM/04_querySelector.js at master · last-endcode/JavaScript-DOM · GitHub
last-endcode
/
JavaScript-DOM
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
1
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
JavaScript-DOM
/
04_querySelector.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
34 lines (29 loc) · 1.03 KB
Breadcrumbs
JavaScript-DOM
/
04_querySelector.js
Copy path
File metadata and controls
34 lines (29 loc) · 1.03 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/*
querySelector - for single
querySelectorAll - for multiple
*/
// querySelector
const
memberShp
=
document
.
querySelector
(
'#shp'
)
;
console
.
log
(
memberShp
)
;
//not node list output show element id shp
// so u can add background without index
memberShp
.
style
.
background
=
'#333'
;
memberShp
.
style
.
width
=
'16rem'
;
//querySelectorAll
const
allMember
=
document
.
querySelectorAll
(
'#shp'
)
;
// check use log if node-list use index
console
.
log
(
allMember
)
;
//here is node-list
const
allMembers
=
[
...
allMember
]
;
allMembers
.
forEach
(
function
(
items
)
{
items
.
style
.
color
=
'#fff'
;
items
.
style
.
textTransform
=
'uppercase'
;
items
.
style
.
padding
=
'2rem'
;
}
)
;
// here u should use querySelector, so why?
// because only querySelector only acces for first
// change first-child be red background and actuallly
// u can write without first-child if want change lutfy be red
const
beRed
=
document
.
querySelector
(
'li'
)
;
beRed
.
style
.
background
=
'coral'
;
// and last-child be blue
const
beBlue
=
document
.
querySelector
(
'li:last-child'
)
;
beBlue
.
style
.
background
=
'blue'
;
Back
|
FazBrowse Home
|
New Git URL