- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path09_textContent.js
More file actions
Latest commit
14 lines (12 loc) · 517 Bytes
/
Copy path09_textContent.js
File metadata and controls
14 lines (12 loc) · 517 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
// textContent for getText
// same with childNodes
constuseChildNodes=document.querySelector('h3');
// only childNodes get index node-list, so use []
// if not will undefined
// if not use nodeValue will write like "Hello people"
console.log(useChildNodes.childNodes[0].nodeValue);
// but for efisien use textContent
constuseTextContent=document.querySelector('h2');
console.log(useTextContent.textContent);
// here textContent can change element h2 too
useTextContent.textContent='Change Text Content h2';