<html>
<body>
<ul id="myList">
<li>Coffee</li>
<li>Tea</li>
</ul>
<p>Click the button get the text content of the ul element.</p>
<button onclick="myFunction()">Try it</button>
<p><strong>Note:</strong> Textual content includes the text of all child nodes as well.</p>
<p><strong>Note:</strong> The textContent property is not supported in Internet Explorer 8 and earlier.</p>
<p id="demo"></p>
<script>
function myFunction() {
var x = document.getElementById("myList").textContent;
document.getElementById("demo").innerHTML = x;
}
</script>
</body>
<!-- Mirrored from www.w3schools.com/jsref/tryit.asp?filename=tryjsref_node_textcontent2 by HTTrack Website Copier/3.x [XR&CO'2014], Mon, 27 Jan 2020 03:02:21 GMT -->
</html>