How to call a function in JavaScript

{0 Comments}

To call a JavaScript function you need JavaScript function name which you want to call. Let’s, consider the following JavaScript which you want to call. To call you have to write the name of function in an event like on click and write () at the last as shown below which is proper syntax to call a JavaScript function.  

 Javascript |  copy code |? 
1
 function Nameoffunction()
2
{
3
alert("Hello World!");
4
}

to call a JavaScript

 Javascript |  copy code |? 
1
 <input onclick=" Nameoffunction ()" type=”submit” >Try it</input>

Leave a Comment

Your email address will not be published.