Home / Programs / How JavaScript can change HTML content
Programming Example

How JavaScript can change HTML content

👁 489 Views
💻 Practical Program
📘 Step by Step Learning
How JavaScript can change HTML content

Program Code

<!DOCTYPE html>
<html>
<body>

<h2>What Can JavaScript Do?</h2>

<p id="demo">JavaScript can change HTML content.</p>

<button type="button" onclick='document.getElementById("demo").innerHTML = "Hello JavaScript!"'>Click Me!</button>

</body>
</html>

Output

Run Above Code

Explanation

no

How to learn from this program

First read the algorithm, then study the program code line by line. After that, compare the code with the output and finally go through the explanation. This approach helps learners understand both the logic and the implementation properly.