Skip to content

Commit 8dde549

Browse files
committed
Add Chapter 8: 1_innerHTML.js
1 parent d838f94 commit 8dde549

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
console.log("ineerHTML and outerHTML in js");
2+
3+
let first = document.getElementsByTagName('span')[0]
4+
5+
console.log(first);
6+
7+
console.dir(first);
8+
9+
// console.log(document.body.firstChild.nodeName)
10+
11+
// console.log(document.body.firstElementChild.nodeName)
12+
13+
// console.log(first.innerHTML); // output: Hey I am span
14+
15+
// first.innerHTML = "Hey I am changed"; // reload the page to see the change
16+
17+
// console.log(first.outerHTML); // output: <span>Hey I am span</span>
18+
19+
// first.outerHTML = "<h1>Hey I am changed</h1>"; // reload the page to see the change
20+
21+
// first.outerHTML = "<div>Hey</div>";
22+
// console.log(document.body.firstChild); // " Hello World "
23+
24+
// console.log(document.body.firstChild.nodeValue); // "\n Hello world\n"
25+
26+
// console.log(first.textContent); // output: Hey I am span
27+
28+
// first.textContent = "Hey I am changed"; // reload the page to see the change
29+
30+
// first.hidden = true;

0 commit comments

Comments
 (0)