Function
Advertisements
Function
An important part of JavaScript is the ability to create new functions within <script> and </script> tag. Declare a function in JavaScript using function keyword. The keyword function precedes the name of the function.
Syntax
function functionName(parameter or not) { ......... ......... }
Example of JavaScript using Function
Example
<html> <head> <script> function getname() { name=prompt("Enter Your Name"); alert("Welcome Mr/Mrs " + name); } </script> </head> <form> <input type="button" value="Click" onclick="getname()"/> </form> </html>
Example
Google Advertisment