<!DOCTYPE html>
<html>
<body>

<p>This example demonstrates the differences between the textContent and innerHTML property.</p>

<ul id="myList">
  <li id="item1">Coffee</li>
  <li id="item2">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><strong>Note:</strong> The textContent property is not supported in Internet Explorer 8 and earlier.</p>

<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>