<!DOCTYPE html>
<html>
<body>
<p>This example demonstrates the differences between the textContent and innerHTML property.</p>
<ul id="myList">
<li>Coffee</li>
<li>Tea</li>
</ul>
<p>Click the button get the text content or HTML content of the ul element.</p>
<button onclick="getText()">Get textContent</button>
<button onclick="getHTML()">Get innerHTML</button>
<p id="demo"></p>
<script>
function getText() {
var x = document.getElementById("myList").textContent;
document.getElementById("demo").innerHTML = x;
}
function getHTML() {
var x = document.getElementById("myList").innerHTML;
document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>