-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path111.js
More file actions
21 lines (21 loc) · 858 Bytes
/
Copy path111.js
File metadata and controls
21 lines (21 loc) · 858 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
const rootNode = document.getRootNode();
const htmlElementNode = rootNode.childNodes[0];
// console.log(htmlElementNode.childNodes); NodeList(3)[head, text, body]
const headElementNode = htmlElementNode.childNodes[0];
const textNode1 = htmlElementNode.childNodes[1];
const bodyElementNode = htmlElementNode.childNodes[2];
console.log(headElementNode.childNodes);
// sibling relation
const h1 = document.querySelector("h1");
// const body = h1.parentNode.parentNode;
// body.style.color = "#efefef";
// body.style.backgroundColor = "#333"
const body = document.body
body.style.color = "#efefef";
body.style.backgroundColor = "#333"
const head = document.querySelector("head");
console.log(head);
const title = head.querySelector("title");
console.log(title.childNodes);
const container = document.querySelector(".container");
console.log(container.children);