This article introduces three basic content syntaxes, dom operation tree, and document objects that are important to learning javascript.
Part 1 Basic Syntax:
1. Data Type (string, decimal, integer, Boolean, and time date)
The Code is as follows:
Var s = "3.14" var n = parsefloat (s) s + = 5;
Var s = "abc3.14" var n = parsefloat (s) // NaN s + = 5; // parse and convert to decimal type
Var d = parseInt (s) // parse and convert to integer type
IsNaN (string), a string that determines whether it is a number or not, is-false; no-true
2. Variables
3. Operators: four categories
4. expression (for statement composition): Variable + operator
5. Statements: three categories ()
Category:
Sequence
Branch: if; if... else, if... else... if... else; if nested
Switch... case
Cycle: exhaustive method, iterative method, and four elements (initial condition, cyclic condition, cyclic body, and state change)
For...
While...
6. Array: var a = new Array ();
7. function: four elements (name, input, return, and processing)
The Code is as follows:
Function show ()
{
}
1. Operators
Comparison operators (7 types): = /! =/>/ =
===( All equals)
2. Usage of string substring
3. Exercise questions: Accumulate sum (using Js)
4. hexadecimal conversion
Part 2 DOM operation (html operation) Tree
Windows Object-browser window
Invalid parameter Doc ument.
Window. alert ()]
Window. location -- Address Bar
Window. history -- forward and backward (Access history)
Window. status -- status Bar
Window.doc ument; (important)
Part 3 document Object:
1. Find
Var d = document. getElementById ("element ID ")
Var d = document. getElementsByName ("element name ")
Var d = document. getElementsByTagNme ("element Tag Name ")
2. Operation Element Content
Common elements: hyperlinks and Images
There are two types:
(1) form elements (Class 3) text (imput: type = text, password, textarea, hidden), buttons (submit/reset/button/image), select (radio/checkbox/select drop-down list, list box/file)
Value assignment d. value = xxxx;
Value: var s = d. value
(2) Non-form elements: h1...... h6; p; span; ul; ol; li (memorizing News)
Control format label
Content container label:
Value assignment: d. innerHTML = xxxx;
Value: var s = d. innerHTML;
3. Operation element attributes
D. setAttribute (name, value)
Var s = d. getAttribute (name)
D. removeAttribute (name)
4. Operation element style
(1) inline style:
D. style xxxxx = xxxx;
Var s = d. style. backgroudcolor;
(2) class attributes
D. className = ""
5. operation-related elements
Top, bottom, inside and outside