Skip to content
Advertisement

Show the content of the function in the div

How do I show myFunction content in myDiv div? So show “Example”?

JavaScript
JavaScript
JavaScript

Advertisement

Answer

This code:

JavaScript

Should be this:

JavaScript

With the id tag inside <p>

And this:

JavaScript

Should also get called since it is a function and not just the document.getElementById("demo").innerHTML = "Example!";

Example 1:

JavaScript

JavaScript
JavaScript
JavaScript

Example 2:

JavaScript

JavaScript
JavaScript
JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement