Element innerHTML Property - Alert the HTML content of a <p> element with id="demo": - Javascript DOM

Javascript examples for DOM:Element innerHTML

Description

Element innerHTML Property - Alert the HTML content of a <p> element with id="demo":

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<p id="demo">Click the button.</p>

<button onclick="myFunction()">Test</button>

<script>
function myFunction() {//w w w.ja  v  a  2  s.c o m
    console.log(document.getElementById("demo").innerHTML);
}
</script>

</body>
</html>

Related Tutorials