JavaScript Knowledge points Summary

Source: Internet
Author: User

1, JavaScript concept: is a language of expression, is also an object-based (objects) and event-driven (EventDriven), the security of good scripting language, running on the client, thereby reducing the burden on the server side, summarized as follows:

1.javaScript is mainly used to find the HTML page to add interactive behavior.

2.javaScript is a scripting language, and syntax is similar to java.

3.javaScript is typically used to write client script.

4.javaScript is an explanatory language that is interpreted by the side of the execution side.

2, JavaScript by the core syntax ECMAScript, browser object model (BOM) is mainly used to manage the window and the communication between the window, so its core object is window, Document Object Model (DOM) composed of three parts.

3, the introduction of JavaScript in the Web page Three ways:

1. Use the <Script></Script> label inner style

2. Using an external JS file

3. Inline style directly in the HTML tag.

The role of 4.javaScript

1. Implement page Form validation

2. Implement page interaction effects

Features of 5.javaScript

1. Designed to add interactive behavior to HTML pages

2. is one of the most popular scripting languages on the Internet

3. Typically used to write client script

4. It's an explanatory language.

6. How to introduce JavaScript

1. Embed Web pages directly using <Script> tags

2. Using an external JS file

The usual methods of string objects in JS:

    1. ToString (before package), 2.toLowerCase (); toUpperCase ();
    2. CharAt (index); Returns the character at the specified position, indexOf (str,index); Specifies the position of the first occurrence in the string; split (str); splits a string into an array of strings

In JavaScript, the conditional statement switch () {} can pick up a string;

Alert ("hint message");

var isok=confirm ("Confirm box");//returns False if the acknowledgment returns true

Prompt ();p rompt ("Prompt Information", "Input box default information");

Prompt ("Please enter name")

Close ();

Open ();

SetTimeout (); Call a function after a specified millisecond

SetInterval (); Call a function at a specified period of milliseconds

window.open ();

7.Js Syntax:

1. Case-sensitive

2. Note variables, functions and other naming conventions

3. Each line of code ends with a semicolon

The functions in JS:

1. System functions

parseint (); Convert to integer 45.9a convert to 45;a6 conversion returns to Nan (not a number)

IsNaN (judging is not a number)

typeof (Var); Determine what data type

Eval ("5+2"); evaluates an expression value

2. Custom Functions

Function name () {JavaScript code}

Function name (parameter 1, parameter 2) {JavaScript code return value (optional)}

The invocation of a function in JS:

    1. Event name = "Function name (passed parameter value)";
    2. Function name (passed parameter value);

Anonymous functions:

    1. Declaration of an anonymous function:

Var variable name =function (parameter) {function body return value;};

    1. Call

Variable name (parameter)

8. Program calls

1. Add alert (); Method 2. Use Firebug (); method

9.BOM Overview: (Browser object model, browser objects models)

Properties of 1.window Objects

Name

Description

History

Information about URLs that customers have visited

Location

Information about the current URL

Screen

Information about the client's screen and display performance

Common methods of Weindow objects: Prompt () confirm (); SetTimeout (); SetInterval ();

Events commonly used by Window objects: onload= "" onmouseover= "; onclick

Window.parent.location

2.History objects

Method: Back (); forward (); Go ();

3.Location object provides the URL of the current page

Property: host hostname href

Method: Reload () replace ();

4.Document objects

Property: The referrer property is determined not to be accessed by a hyperlink, not to return null

Objects in the 10.javaScript,

Date object:

Create a Date object method var date=new date (MM DD, YYYY,HH:MM:SS);

var date=new date (); Date.getday ();

Math object:

Ceil (); Logarithmic rounding up, ceil (25.5) = 26;

Floor (); Rounding down, floor (25.5) = 25;

Math.Round (25.5), rounding down after adding 0.5 of the original number

11.Dom Overview (Document Object model)

Made up of coredom,xmldom,html dom;

12. Creating an array

The declaration of variables in JS:

Var array name =new array (size);

    1. First declare the re-assignment fruit[0]= ""
    2. Declare both the Var fruit=new Array ("Apple", "orange"), or the Var fruit=new array["Apple", "orange";

Read 1. Use for loop to read 2. Using for---in read

for (var x in fruit) {document.write (fruit[x]+ "<br/>")}x as Subscript

Fruit.sort ();//Sort string Str=fruit.join ("-");//Add string and concatenate it into a string

Drop-down list select object:

  

13 Styles of Style positioning

Left top position Z-index

Mouse scrolling Distance: scorlltop: longitudinal distance

Scorllleft: Transverse distance

Mouse scrolling Leave: onscorll

The mutual conversion of jquery objects to DOM objects

    1. jquery objects are converted to DOMD objects, and jquery provides two ways to convert jquery objects to DOM objects, that is, [index] and get (index).

var $txtName =$ ("#txtName");//jquery Object

var txtname= $txtName [0];//dom Object

alert (txtname.checked);//detects if the checkbox is selected

Get the corresponding DOM object using the Get (index) method

Var $txtName =$ ("#txtName");//jquery Object

Var txtname= $txtName. Get (0);//dom Object

alert (txtname.checked);//detects if the checkbox is selected

    1. Dom object converted to jquery object

Var Txtname=document.getelementbyid ("txtname");//dom Object

Var $txtName =$ (txtname);//

Add Class attribute in DOM using Obj.classname=classname;

Add class capacity using Obj.innerhtml=<input/>

Add Class attribute in jquery using Obj.addclaa=classname;

Adding a class capacity using:obj.html=<input/>;

The five major selectors in Jqurey:

    1. Basic selector (#. Label
    2. Hierarchy selector (Descendants > children + Neighboring ~ peers)
    3. Property selector (P[class=name])
    4. Filter selector ("Tr:even")
    5. Visibility selector ("P:hidden" "P:viside")

Events in jquery:

Obj.bind ("Clike", function () {});

Obj.bind ({mousever:function () {},{mouserout:function () {}}});

Obj.unbind ();

Obj.hover (function () {},function () {}) method collection onmouseover and onmouseout

Obj.toggle ();

$ (". Tipsbox"). Show (); Obj.hide ();

$ ("img"). FadeIn (1000);

$ (". txt"). Slideup (1000); Obj.slidedown (1000);

Obj.toggleclass ("class");//integration of AddClass and Romoveclass

$ (this). Val ("");//Clear Text contents

Var $newNode =$ (< <li> Create new element node </li> > with jquery);

In regular expressions

  

JS commonly used in some of the tips:

1. Use!! The operator converts the Boolean value, which can be used for variables!! Varable do the detection, as long as the value of the variable is: 0,null, "", Undefind or Nan will return false and vice versa is true
Function account (Cash)
{
This.cash = cash;
This.hasmoney =!! Cash
}
2. Use + to convert a string to a number, only for string data, otherwise return Nan
function Tonumber (strnum) {
return +strnum;
}
Applies to date () returns timestamp number: +new date ();
3. When the loop is very large, the length of the number is first given out, var legth = array.legth;

4.if (' Queryselector ' in document) {
Document.queryselector ("#id");
} else {
document.getElementById ("id");
}

5. Get the last element in the array
var array = [1,2,3,4,5];
Array.slice (-1);
6. Substitution of string elements
var string = "John John";
String.Replace (/hn/, "Ana"); "Joana John."
String.Replace (/hn/g, "Ana"); "Joana Joana"

JavaScript Knowledge points Summary

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.