Javascript functions are reusable blocks of code that can make life so much easier.
If you have done any programming then you can think of functions as similar to subroutines. This section will show you typical syntax and how to call the function. Try example 3
Example 3 code
<html>The function syntax is
function NAME(){Give your functions an appropriate name, it makes maintenance easier. Notice that () appear after the function name, make sure that there is no space before the () - example myfunction()
The code for the function must be placed between the {} for the function to work properly.
In the above example we are calling the function from an onclick event. The action we want to apply to the onclick event is example1(); - By clicking on the link text, the code within the example1 function is run.
We will expand on using functions after an introduction to variables.