Edit This Code:
<!DOCTYPE html>
<html>
<body>

<p>The first p element in the document.</p>
<p>Another p element.</p>

<p>Click the button to get the HTML content of the first p element (index 0) in this document.</p>

<button onclick="myFunction()">Try it</button>

<p id="demo"></p>

<script>
function myFunction() {
    var nodelist = document.getElementsByTagName("P").item(0).innerHTML;
    document.getElementById("demo").innerHTML = nodelist;
}
</script>

</body>
</html>


Result:
Try it Yourself - © w3schools.com
Privacy Policy