Basic JavaScript syntax, dom operation tree, and document object_basic knowledge

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.