Home / Programs / Writing into an HTML element using Javascript
Programming Example

Writing into an HTML element using Javascript

👁 365 Views
💻 Practical Program
📘 Step by Step Learning

In this section you will learn how to writing into an HTML element using JavaScript.

Program Code

<!DOCTYPE html>
<html>
<body>

<h2>Writing into an HTML element</h2>
<p>My First Paragraph.</p>

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

<script>
document.getElementById("demo").innerHTML = 10 + 11;
</script>

</body>
</html> 

Output

21

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.