How to call JavaScript function in html?

Today, We want to share with you call javascript function from html.In this post we will show you calling javascripts function from html onload, hear for html call javascripts function on load we will give you demo and example for implement.In this post, we will learn about How To Define And calling A Function In Javascripts? with an example.

html call javascript function onclick

Example 1:

<html>
 <head>
  <script type="text/javascript">
function getInfo() { alert('You clicked the top text'); }
function lastDemoExample() { alert('You simple clicked the bottom data text'); }
  </script>
 </head>
<body>
 <p><a href="#" onClick="getInfo();">Top Text</a></p>
 <p><a href="javascript:lastDemoExample();">Bottom Text</a></p>
 </body>
</html>

JavaScript Return Value

Example 2:

<html>
<head>
	<script type="text/javascript">
		function finalTotal(startnumber, lastnumber)
        {
          var total = startnumber + lastnumber;
          return total;
        }
      var startnumber = 78;
      var lastnumber = 22;
      document.write(startnumber + " + " + lastnumber + " = " + finalTotal(startnumber,lastnumber));
	</script>
</head>
<body>
</body>
</html>

How to calling a JavaScripts function from an onClick event?

Example 3:

<html>
   <head>
      <script>
         <!--
            function print_name() {
               alert("Welcome To Zakhi")
            }
         //-->
      </script>
   </head>
   <body>
      <p>Click the Bellow button and display output</p>
      <form>
         <input type="button" onclick="print_name()" value="Click me" />
      </form>
   </body>
</html>

I hope you get an idea about calling javascript function from html form.
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.