<html>
<body>
<p>Click the button get the text content of the button element.</p>
<button onclick="myFunction()" id="myBtn">Try it</button>
<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("myBtn").textContent;
document.getElementById("demo").innerHTML = x;
}
</script>
</body>
<!-- Mirrored from www.w3schools.com/jsref/tryit.asp?filename=tryjsref_node_textcontent by HTTrack Website Copier/3.x [XR&CO'2014], Mon, 27 Jan 2020 03:02:21 GMT -->
</html>