JavaScript basics syntax, DOM operation tree and Document Object _ Basics

Source: Internet
Author: User
Tags tag name

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:

Function Show ()
{
}

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

Related Article

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.