Get the HTML content of a <ul> element with id="myList"
:
var x = document.getElementById("myList").innerHTML;
Click the button get the HTML content of the ul element.
<!DOCTYPE html> <html> <body> <ul id="myList"> <li>CSS</li> <li>HTML</li> </ul>//from www. ja v a 2 s. co m <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() { var x = document.getElementById("myList").innerHTML; document.getElementById("demo").innerHTML = x; } </script> </body> </html>