Element innerHTML Property - Get the HTML content of a <ul> element with id="myList": - Javascript DOM

Javascript examples for DOM:Element innerHTML

Introduction

  • Coffee
  • Tea

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<ul id="myList">
  <li>A</li>
  <li>B</li>
</ul>/*  w  w  w . j a v  a 2 s .  c o  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>

Related Tutorials