The first part of the basic syntax:
1, data type (string, Decimal, Integer, Boolean, Time date)
Copy Code code as follows:
var s= "3.14" var n=parsefloat (s) s+=5;
var s= "abc3.14" var n=parsefloat (s)//nan s+=5;//parse Convert decimal
var d=parseint (s)//Resolution to Integer
isNaN (String), to judge whether the string is a digital pattern, is-false; no-true
2, variable
3, operators: four categories
4, expression (for constituent statements): Variable + operator
5, sentence: three categories ()
Classification:
Order
Branch: If;if. Else,if.. else.. If.. Else...if.. Else;if nesting
Switch...case
Cycle: Exhaustive method, iterative method, four elements (initial condition; cyclic conditions; circulation body; State change)
For .....
While ...
6, array: var a= new Array ();
7, Function: Four elements (name, input, return, processing)
Copy Code code as follows:
1, operator
Comparison operators (7 types): ==/===/!=/>/</<=/>=
= = = (all equals)
2, the use of string substring
3, Exercise: Add sum (using JS method)
4, the conversion of the system
Part two DOM operations (manipulating HTML) tree
Windows Object--browser window
[Window.document.
Window.alert ()]
window.location--Address Bar
window.history--forward and backward (visit history)
window.status--status bar
Window.document; (emphasis)
Part III Document Object :
1, find
var D=document.getelementbyid ("Element ID")
var d=document.getelementsbyname ("Name of Element")
var d=document.getelementsbytagnme ("tag name of element")
2, Operation element content
Common elements: hyperlinks, pictures
Divided into 2 categories:
(1) Form element (3 Class) text (Imput:type=text,password,textarea,hidden), button (Submit/reset/button/image), selection (radio/checkbox/ Select Drop-down list, list box/file)
assigning value d.value=xxxx;
Take value var S=d.value
(2) Non-form elements: H1....h6;p;div;span;ul;ol;li (Memory News)
Control format Labels
Content Container Label:
Assign value: d.innerhtml=xxxx;
Take 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 attribute
D.classname= ""
5, Operation related elements
Top, bottom, inside and outside