laitimes

Moving web pages – getting started with JavaScript

author:Document

Our web page has a lot of dynamic interaction effects, such as mouse slides, clicks, keyboard click trigger effects, etc., which cannot be completely completed by our CSS style, and need to rely on our JavaScript (hereinafter referred to as JS) code to complete.

The JS reference is very simple, he and CSS reference is very similar, the first: write < script anywhere on the page></script >, just like an HTML tag. Second: We first write a file with an extension named js, and then write < script src="js file path" anywhere on the page></script >.

Although our script tags can theoretically be written anywhere, because JS is single-threaded, that is, our browser can only read our code line by line, so that our code will have order problems, so that in actual programming, JS code can not write the position, there may be a problem of not getting the value. I personally write code that is usually written after the end tag of the body, i.e. between the </body > and the </html/> tag.

Our JS language is a weakly typed language, there is no strict type difference between C and Java and other languages, so we only need a var to define variables when writing JS code (es6 added the method of let and const to define variables), and JS's definition variables are a bit arbitrary, such as var a (asking the system for a space a (a is also called a variable)); a = 100 (assigning 100 to a); Can also be written as var a, b, c; a=100,b=200,c=300; It can also be written as var a=100, b=200;

Our variables have naming conventions: 1. Variable names must start with the English letters, _ (underscore), $. 2. Variable names can contain English letters, _ (underscore), $ and numbers.3. It is not possible to use the keywords of the system (which have been defined as names with special meaning), reserved words as variable names (set by the system to names that may be defined in the future), for example: if, while, else, etc. have special meaning or are defined as names that may have special meaning in the future.

Welcome to leave a message criticizing and advising [Flying Kiss]