Javascript examples for DOM:Element textContent
Element textContent Property - Get all the textual content of an <ul> element with id="myList":
<!DOCTYPE html> <html> <body> <ul id="myList"> <li id="item1">Coffee</li> <li id="item2">Tea</li> </ul>//from ww w .j a va2 s. c o m <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() { var x = document.getElementById("myList").textContent; document.getElementById("demo").innerHTML = x; } </script> </body> </html>