JavaScript (JS)

Source: Internet
Author: User

1 1.1---JavaScript basic syntax (-)-Introduction, implementation, output:

Scripts in HTML must be located between <script></script> tags

Scripts can be placed in the <body> and

Write code between <script></script>

Usage Restrictions:

In HTML, do not limit the number of scripts (can use many pairs <script></script> tags)

Scripts are usually placed in the

Can create JS (in the JS file does not need to use the script tag) file, directly through the src= "JS filename" in the HTML file using the JS scripting language

Javascipt output:

Document output: document.write ("

You need to use "" and you can use labels directly in the output statement.

1.2---JavaScript basic syntax (-)-Syntax and annotations:

JS statements like a browser issue commands. The purpose of the statement is to tell the browser what to do.

Semicolon: The split between statements is a semicolon (;)

Note that semicolons are optional, and sometimes you see that they are not separated by semicolons. (for writing specifications, preferably with)

In addition, JS syntax and comments and C language almost the same as (case-sensitive), I am not redundant, just say the difference:

JS identifiers begin with a letter, underscore, or dollar sign .

JS will ignore the extra spaces. line breaks between code letters are not allowed.

Another thing to say:

JS executes sequentially in the written order, but if the following statements overwrite the previous statement, the preceding statement is equivalent to no writing.

That is, the preceding statement is overwritten directly.

such as: Doucument.getelementbyid ("pid"). Innerhtml= "HH";

Doucument.getelementbyid ("pid"). Innerhtml= "MM";

Last output mm only;

JavaScript (JS)

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.