JavaScript function calls

Source: Internet
Author: User

One, the first case: called within the <script></script> tag.

  

1<script type= "Text/javascript" >2     functionAdd ()3     {4sum = 1 + 2;5 alert (sum);6     }7Add ();//call the function and write the function name directly. 8</script>9 Ten Another way of writing One<script type= "Text/javascript" > A     functionAdd (A, b) { -sum = a +b; - alert (sum); the}//just write it once and you can -Add (1, 2);
    Add (3, 4);//If more than one will follow the display
 </script>

Two, the second situation: called in the HTML file, such as by clicking on the button to invoke the defined function.

  

<HTML><Head><Scripttype= "Text/javascript">   functionAdd () {sum=1+2;   alert (sum); }</Script></Head><Body><form><inputtype= "button"value= "point Me"onclick= "Add ()">//button, onclick Click event, direct write function name</form></Body></HTML>

JavaScript function calls

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.