Tryit Editor v2.3

Edit This Code:
<!DOCTYPE html> <html> <body> <ul id="myList"> <li id="item1">Coffee</li> <li id="item2">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], Fri, 23 Jan 2015 08:29:05 GMT --> </html>
Result:
Try it Yourself - © w3schools.com