Home >Web Front-end >JS Tutorial >JavaScript basic syntax, DOM operation tree and document object_Basic knowledge
Part 1 Basic Grammar:
1. Data type (string, decimal, integer, Boolean, time and date)
2. Variables
3. Operators: Four categories
4. Expression (to form a statement): variable operator
5. Statements: three major categories ()
Category:
Order
Branch: if;if..else,if..else..if..else...if..else;if nesting
switch...case
Loop: exhaustive method, iteration method; four elements (initial conditions; loop conditions; loop body; state change)
for...
while...
6. Array: var a= new Array();
7. Function: four elements (name, input, return, processing)
1. Operator
Comparison operators (7 types): ==/===/!=/>/<=/>=
=== (all equal to)
2. Usage of string substring
3. Practice question: Accumulation and summation (using Js method)
4. Base conversion
Part 2 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; (emphasis)
Part 3 document object :
1. Find
var d=document.getElementById("ID of element")
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 elements (category 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;
Value var s=d.value
(2) Non-form elements: h1....h6;p;div;span;ul;ol;li (memory news)
Control format tag
Content container tag:
Assignment: d.innerHTML=xxxx;
Value: var s=d.innerHTML;
3. Manipulate 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.backgroundcolor;
(2)class attribute
d.className=""
5. Operation related elements
Up, down, inside, outside