Javascript: Change Content

Javascript can change HTML content:

HTML file: Displayed by browser:
<!DOCTYPE html>
<html>
<body>

<h1>My First JavaScript</h1>

<p>JavaScript can change the content of an HTML element:</p>

<button type="button" onclick="myFunction()">Click Me!</button>

<p id="demo">==> Watch This Change! <== This is a demonstration.</p>

<script>
function myFunction() {
    document.getElementById("demo").innerHTML = "Hello JavaScript!";
}
</script>

</body>
</html>

My First JavaScript

JavaScript can change the content of an HTML element:

==> Watch This Change! <== This is a demonstration.


Back button Table of Contents Next button