- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path03_getElementByClassName.js
More file actions
Latest commit
16 lines (13 loc) · 584 Bytes
/
Copy path03_getElementByClassName.js
File metadata and controls
16 lines (13 loc) · 584 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// getElementByClassName('classname')
// For class name
// node-list = array like object
// index, length property but not array method
constbackground=document.getElementsByClassName('container');
constlist_item=document.getElementsByClassName('list-item');
// remember if write this without index will undefined
// cause background result is use node-list index
// background.style.background = 'blue'; //wrong
background[0].style.background='blue';
background[0].style.height='40vh';
list_item[0].style.color='white';
list_item[0].style.textTransform='uppercase';