-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdom.html
36 lines (28 loc) · 1006 Bytes
/
dom.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<!DOCTYPE html>
<html>
<body>
<h1>The Element Object</h1>
<h2>The Differences Between innerText, innerHTML and textContent</h2>
<p id="myP"> This element has extra spacing and contains <span>a span element</span>.</p>
<button onclick="getinnerHTML()">Get innerHTML</button>
<button onclick="getinnerText()">Get innerText</button>
<button onclick="gettextContent()">Get textContent</button>
<pre id="demo"></pre>
<p>The innerText property is not supported in IE 9 and earlier.</p>
<p>The textContent property is not supported in IE 8 and earlier.</p>
<script>
function getinnerText() {
let text = document.getElementById("myP").innerText;
document.getElementById("demo").innerText = text;
}
function getinnerHTML() {
let text = document.getElementById("myP").innerHTML;
document.getElementById("demo").innerText = text;
}
function gettextContent() {
let text = document.getElementById("myP").textContent;
document.getElementById("demo").innerText = text;
}
</script>
</body>
</html>