Element textContent Property - Change the textual content of a <p> element with id="myP": - Javascript DOM

Javascript examples for DOM:Element textContent

Description

Element textContent Property - Change the textual content of a <p> element with id="myP":

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<p id="demo" onclick="myFunction()">Click me to change my textual content.</p>

<script>
function myFunction() {//from  ww  w.j  a va2s.c  o  m
    document.getElementById("demo").textContent = "Paragraph changed!";
}
</script>

</body>
</html>

Related Tutorials