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

Javascript examples for DOM:Element innerHTML

Description

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

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<p id="myP">I am a paragraph.</p>

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

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

<script>
function myFunction() {/*from ww w.j  a v a2  s.c om*/
    var x = document.getElementById("myP").innerHTML;
    document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

Related Tutorials