<body> elements within
a webpage. However, to ensure that functions are available when they are called, they should be placed within the <head>
element so they are downloaded by the browser prior to the page's content.
Here is an example of the syntax for a function.
function functionName(variable#1, variable#2, etc..)|
In the example above, the parameters variable#1, variable#2, etc. are variables that are passed into the function. The braces define the start and end of the function. If the function does not
lowercase. Let's take a look at an example of how this would be implemented within a webpage.
<input type="button" value="Click Here" onclick="displayalert()" />
will not execute during the page load. It will only execute when the
function is called from within the page. In this example, we call the
function by clicking on the input button located in the <body> element.
back to the object that made the call to the function. The return statement is used
for this purpose. Here is an example on how to use the return statement within a function.
<input type="button" value="Add 2+3" onclick="alert(addTwoNum(2,3));" />
Recommended Books & Training Resources