how to print javascript variable in html tag?

Today, We want to share with you print javascript variable in html.In this post we will show you how to display javascript variable value in html table?, hear for display javascript variable in html div we will give you demo and example for implement.In this post, we will learn about
How to display javascript variable in html?
with an example.

Read Also:  jquery get attribute value - How to get HTML attribute values in JQuery?

how to display a javascript var in html body?

Example 1: index.html

<html>

<head>
  <script>
    function getOnlineData() {
      var registeration_number = "98256";
      document.getElementById("exampleData").innerHTML = registeration_number;
    }
  </script>
</head>

<body onload="getOnlineData()">

  <h1>"The value for registeration number is: " <span id="exampleData"></span></h1>

</body>

</html>

Example 2: Use document.write()

<html>
<head>
  <script type="text/javascript">
    var registeration_number = 98256;
  </script>
</head>

<body>
    <h1>
      the value for registeration number is:
      <script type="text/javascript">
        document.write(registeration_number)
      </script>
    </h1>
</body>
</html>

I hope you get an idea about how to display jquery variable value in html page.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.