- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path06_parentElement.js
More file actions
Latest commit
16 lines (14 loc) · 607 Bytes
/
Copy path06_parentElement.js
File metadata and controls
16 lines (14 loc) · 607 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// parentElement
// for knowing where your classes or id
constmyParent=document.querySelector('.members');
// ul #shp is parent
console.log(myParent.parentElement);
// div .container is parent
console.log(myParent.parentElement.parentElement);
// body is parent and if add parentElement again will null
console.log(myParent.parentElement.parentElement.parentElement);
// example
constbodyBackground=document.querySelector('.container');
constcontainerColor=document.querySelector('#shp');
containerColor.parentElement.style.color='#fff';
bodyBackground.parentElement.style.background='#333';