Calling function in javascript need to call from attribute of html
attribute can call events of javascript
in input element onclick we can call function of javascript
<html> <head> <title>Call function</title> <script> function callFunction() { alert("Calling function in javascript"); } </script> </head> <body> <input type="button" name="callName" value="call" onclick="callFunction()" /> </body> </html>
Demo
<html> <head> <title>Javascript Call function</title> <script> function callFunction() { alert("Calling function in javascript"); } </script> </head> </head> <body> Function calling automatically <script> callFunction(); </script> </body> </html>
If function need to pass by value
check out example
<script> function callFunction(obj1, obj2) { alert(obj1+" : "+obj2) } </script>
This function can call like this
<input type="button" name="cf" value="go" onclick="callFunction('2','5')" />



Link to Us