Part 1 Basic Syntax:
1. Data type (string, decimal, integer, boolean, time and date)
The code copy 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 conversion to decimal type
var d=parseInt(s)//Parse to integer type
isNaN (character string), determines whether it is a numerical string, is -false; no-true
2. Variables
3. Operator: Four categories
4. Expression (to make up a statement): variable + operator
5. Statement: Three categories ()
Classification:
order
Branches: if;if..else,if..else..if..else...if..else;if nesting
switch...case
Circulation: exhaustive method, iterative method; four elements (initial conditions; cyclic conditions; cyclic body; state change)
For...
While...
6. Array: var a= new Array();
7. Function: Four elements (name, input, return, processing)
The code copy is as follows:
function show()
{
}
1. Operator
Comparison operators (7 types): ==/===/!=//</<=//=/
===(all equal to)
2. Usage of string substring
3. Exercise questions: Accumulation sum (using Js method)
4. Calculation conversion
The second part of the DOM operation (operation html) tree
windows object-browser window
[window.document.
window.alert()]
window.location--address bar
window.history--Forward, Backward (Access History)
window.status--status bar
window.document; (key point)
Part 3 document object :
1. Find
var d=document.getElementById("Id of element")
var d=document.getElementsByName("name of element")
var d=document.getElementsByTagNme("Tagname of element")
2. Operation element content
Common elements: hyperlinks, pictures
Classified by 2 categories:
(1) Form element (class 3) text (imput: type=text, password, textarea, hidden), button (submit/reset/button/image), selection (radio/checkbox/select drop-down list, list box/file)
Assign value d.value=xxxx;
Take the value var s=d.value
(2) Non-form elements: h1....h6;p;div;span;ul;ol;li (memory news)
Control format tags
Content container tag:
Assignment: d.innerHTML=xxxx;
Value: var s=d.innerHTML;
3. Operate 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
Up, down, inside, outside