JavaScript (reprinted from the Academy of Science and Education Network)

Source: Internet
Author: User
Tags logical operators rounds static class

What is a scripting language?

① scripting language between HTML and c,c++,java,c# programming languages

② scripting language has a similar place to programming language, and its functions are similar to programming languages, and there are variables. The biggest difference from programming languages is that the syntax and rules of a programming language are stricter and more complex.

③ scripting language is an explanatory language, such as Python, Vbscript,javascript, and so on, unlike c\c++, which can be compiled into binary code, in the form of executable files.

④ scripting language generally has a corresponding scripting engine to explain execution, JavaScript scripting engine is the browser

JavaScript is primarily intended for client-side programming (browsers) and server programming.

Event Source (Event object) event handler

mouse events;

keyboard events;

HTML events;

other events;

var a=10: Defines a variable with a value of 10 for the variable named A,a

Window.alert (a): Frame display, display () contents

document.write: Web page display (must be prefixed)

Break: Jump out of the loop

Continue: End this round cycle

Parse: Cast

parseint: Cast to an integer.

Parsefloat: Cast to floating-point

Meta charset= ' utf-8 ': Chinese

Script: Display

if (): judging (IF)

else: Otherwise (with if use)

Return: Value returned

For (i=1;i<50;i++): Loop 1

while (I<50): Loop 2

do{}while (i<50): Loop 3

Prompt: Input

getElementById: Sets the return value of an ID connection

Onclick:html Label Connection function

Disabled: text box cannot be clicked input

This: Object-oriented (me)

charCodeAt:

Floor: Fractional conversion of integers, such as 1.9=1;-1.9=-2;

SetTimeout: Timer Execution time

SetTimeout ("C ()", 5) executed every five milliseconds

Cleartimeout: Timing Stop

Function: Defining functions

Function usage: <script type= "Text/javascript" src= "JS (file path)" ></script>

function invocation: JS (JS is the function name), A=JS () (A is the variable name, JS is the function name);

charCodeAt: Returns the Unicode encoding of the character

Eval: Run string

Event.clienty: Display mouse coordinates

Event.clientx:

OffsetTop: Displays the distance from the top edge of the previous element to the top edge of the element

Offsetleft:

Offsetheight: Returns the height of the element

Offsetwidth: Returns the width of the element in pixels. This is a non-standard but well-supported property.

Date () returns the current date and time

GetDate () returns a day in one months from a Date object

GetDay () Returns a day of the week from a Date object

GetMonth () returns the month from the Date object

GetYear () returns the year from the Date object

GetHours () returns the number of hours from the Date object

Getminutes () returns minutes from a Date object

Getseconds () returns the number of seconds from the date object

Math.Abs (x) absolute value of the return number

Math.ceil (x) rounds a number

Math.floor (x) rounds a number down

Math.max (x, y) to find the larger number in X, y

Math.min (x, y) to find the smaller number in X, y

Math.Round (x) rounding X

Math.random () A number of 16-bit decimal digits greater than 0 and less than 1

IndexOf () returns the position of the first occurrence of a string value in the string

Split () splits a string into an array of strings

SUBSTR () extracts the specified number of characters starting from the start subscript

SUBSTRING () extracts a string that is mediated between two specified subscript sub-strings

CharAt () returns the character at the specified position

Length property, you can get the string

The loading of the onabort image is interrupted.

The onblur element loses focus.

The contents of the onchange domain are changed.

OnClick an event handle that is invoked when a user taps an object.

OnDblClick an event handle that is called when the user double-clicks an object.

OnError An error occurred while loading the document or image.

The onfocus element gets the focus.

OnKeyDown A keyboard key is pressed.

onkeypress A keyboard key is pressed and released.

OnKeyUp a keyboard key is released.

OnLoad a page or an image to finish loading.

OnMouseDown the mouse button is pressed.

OnMouseMove (*) mouse is moved.

onmouseout (*) The mouse moves away from an element.

onmouseover (*) moves the mouse over an element.

OnMouseUp mouse button is released.

The onreset reset button is clicked.

OnResize the window or frame is resized.

Onselect text is selected.

OnSubmit confirm button is clicked.

OnUnload user exits the page.

DOM element: (document.)

Createelemnet (sign) Create a node

AppendChild (node) append one node

InsertBefore (node, original node) Insert node before existing element

RemoveChild (node) Delete a node

ChildNodes NodeType Get child nodes

Childrenparentnode Get parent Node

GetAttribute (name) get

SetAttribute (name, value) settings

RemoveAttribute (name) Delete

By: space

<br/>: Line break

. appendchild Add

JS itself provides some of the classes that can be used directly are internal classes:

Mainly include:

JS Array

JS Boolean

JS Date

JS Math

JS number

JS String

The inner classes are divided into:

Static class

How to use static classes

When referencing its properties and methods: Static Class. Method (or property)

How to use dynamic classes

of the Dynamic class

var object instance name =new class ()

object instance name. Method (or familiarity)

String class: One of the dynamic classes.

One array:

1. Arrays can hold any type of data.

2. The array size does not have to be developed beforehand.

3. The array name can be interpreted as a reference to the first address of the array.

4. Array elements are numbered by default starting from 0.

New array: Creating an array

The JS array can grow dynamically

. Split: Splitting a string into a character array

Splits a string string. Split (split standard) to get an array of

Length: Returns the number of numbers in the array

Array name. Length---Usage

for (var key in arr) {Widow.alert (key+ "="-arr[key]);}

Create an array

var a=new Array (3)

A[0]=1;

a[1]=2;

a[2]=3;

Or: Var a=new Array ("1", "2", "3")

Creating a two-dimensional array

var a=new Array ();

for (Var i=0;i<10;i++) {

A[i]=new Array ();

for (Var j=0;j<20;j++) {a[i][j]=1;}

}

ScrollWidth is the width of the actual content of the object, without the width of the edge, which changes with the contents of the object (more content may change the actual width of the object)

ClientWidth is the width of the object visible, without edges such as the scroll bar, which changes with the window's display size.

The offsetwidth is the visible width of the object, and the edges such as the package scroll bar change with the window's display size.

ScrollHeight: Gets the scroll height of the object.

Offsetheight: Gets the object relative to the canvas or by the parent coordinate

ScrollLeft: Sets or gets the distance between the left edge of the object and the leftmost of the currently visible content in the window

Offsetleft: Gets the object relative to the layout or by the

ScrollTop: Sets or gets the distance between the top of the object and the top of the visible content in the window

The OffsetTop property specifies the top position of the calculated parent coordinate

The height of the parent coordinate specified by the OffsetParent property

The OffsetParent property specifies the parent coordinate of the computed left position

Event.clientx horizontal coordinates of relative documents

Event.clienty vertical coordinates of relative documents

Event.offsetx horizontal coordinates relative to the container

Event.offsety the vertical coordinate of the relative container

JS operator

①+ plus ②-minus ③* by ④/in addition to ⑤% to take the mold (take the remainder) ⑥++ self-added ⑦--self-reduction ⑧+= Zoga ⑨-= left minus ⑩/= left except ⑾%= left to take the mold

JS relational operators

①== equals ②> greater than ③< less than ④>= greater than or equal to ⑤<= less than equals ⑥!= not equal to

logical operators

①&& and ②| | or ③! Non -

Academy of Sciences

Mu class net

JavaScript (reprinted from the Academy of Science and Education Network)

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.