How to add text in a html page using javascript ?


A simple example of how to append text in a html page using javascript:

Append text to a div using javascript innerHTML

A basic html page that display "hello world !" using javascript:

<!DOCTYPE html>
<html lang="en">

<head>
    <title>Javascript</title>
</head>

<body>

    <div id="target_div"></div>


    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>

    <script>

        var div = document.getElementById('target_div');

        div.innerHTML += 'hello world !';

    </script>

</body>
</html>

returns

How to add text in a html page using javascript ?
How to add text in a html page using javascript ?

References

Image

of