Python 15th day

Source: Internet
Author: User

   

 Python's Web front section:

Javascript

A. What is JavaScript?

    JavaScript is a programming language, the browser has built-in JavaScript interpreter, so in the browser according to the JavaScript language rules to write the corresponding code, the browser can explain and make corresponding processing.

Two. JavaScript Authoring:

    1. js code exists in the form:

Mode one: Introduce JS file:

1 <  type= "Text/javascript"  src= "js file"></  Script>

Mode two: Directly edit the JS code

1  <  type= "Text/javascript">2        JS code content 3  </ Script >

2. JS Code Placement Location:

(1) between

Since the HTML file is loaded by the browser from top to bottom, you can ensure that the JS code is loaded first.

If the JS code response delay, the user can not see the page for a long time, greatly affected the user experience.

1 <!DOCTYPE HTML>2 <HTMLLang= "en">3 <Head>4     <MetaCharSet= "UTF-8">5     <title></title>6     <Scripttype= "Text/javascript">7 JS Code content8     </Script>9 </Head>Ten <Body> One  A </Body> - </HTML>     

(2) placed in the <body></body> bottom of the HTML file

When the JS code is placed in the <body> bottom, even if the JS code response delay, users can see the Web page, but the JS effect is slightly slower, the impact on the user experience will not be great.

1 <!DOCTYPE HTML>2 <HTMLLang= "en">3 <Head>4     <MetaCharSet= "UTF-8">5     <title></title>6     <Scriptsrc= "https://www.gstatic.com/og/_/js/k=og.og2.en_US.iF4jnkQuaf0.O/rt=j/t=zcms/m=def/exm=in,fot/d=1/ed=1/rs= Aa2yrtv5-poc4ks9gtgrdy2ywuwisqz7-q "></Script>7 <Script>8 Alert (JS code content);9 </Script>Ten </Head> One <Body> A  - </Body> - </HTML>

3. The comments in the JS code:

     As with other languages to provide readability of the code, JS annotations are divided into two types: single-line comments and multiline comments.

(1) Single-line comment:

Start with//

1 <Scriptsrc= "https://www.gstatic.com/og/_/js/k=og.og2.en_US.iF4jnkQuaf0.O/rt=j/t=zcms/m=def/exm=in,fot/d=1/ed=1/rs= Aa2yrtv5-poc4ks9gtgrdy2ywuwisqz7-q ">2 //src Specifies the source link of the JS code3 </Script>4 <Script>5 //Alert output JS code content6 Alert (JS code content);7 </Script>

(2) Multi-line Comment:

Start with/* and end with */.

1 <Scriptsrc= "https://www.gstatic.com/og/_/js/k=og.og2.en_US.iF4jnkQuaf0.O/rt=j/t=zcms/m=def/exm=in,fot/d=1/ed=1/rs= Aa2yrtv5-poc4ks9gtgrdy2ywuwisqz7-q ">2         /*3 src Specifies the source link of the JS code4 Alert output JS code content5         */6 </Script>7  <Script>8 Alert (JS code content);9  </Script>

Three. JavaScript variables

   Like algebra, JavaScript variables can be used to hold values (such as x=2) and expressions (such as z=x+y).

Variables can use short names (such as x and y), or they can use better descriptive names (such as age, Sum, totalvolume).

      • Variables must start with a letter
      • Variables can also start with the $ and _ symbols (although we do not recommend this)
      • Variable names are case sensitive (Y and y are different variables)

JS variables are divided into local variables and global variables:

Note: Both JavaScript statements and JavaScript variables are case-sensitive.

  

Python 15th day

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.