JavaScript Knowledge points Summary (must see article) _ Basic knowledge

Source: Internet
Author: User
Tags anonymous bind object model setinterval

1, the concept of javascript: is a language of expression, but also an object-based (object) and event-driven (EventDriven), secure script language, running on the client, thereby reducing the burden on the server side, summed up as follows:

1.javaScript is mainly used to find that add interaction behavior to HTML pages.

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, which is performed while interpreting.

2, JavaScript by the core syntax ECMAScript, browser object model (BOM) is mainly used to manage the communication between windows and Windows, 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 <Script></Script> label internal style

2. Use 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

The characteristics of 5.javaScript

1. is designed to add interactive behavior to HTML pages

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

3. Generally used to write client script

4. It's an interpretive language.

6. How to introduce JavaScript

1. Embed Web pages directly using <Script> tags

2. Use external JS file

Common methods for String objects in JS:

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

Conditional Statement switch () {} Can connect strings in JavaScript;

Alert ("Hint info");

var isok=confirm ("Confirm box");//return FALSE if confirmation 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 in the 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

Functions in JS:

1. System function

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

isNaN (Judging is not the number)

typeof (Var); Determine what data type

Eval ("5+2"); Evaluation of expression values

2. Custom function

function functions Name () {JavaScript code}

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

Calls to functions in JS:

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

anonymous function:

    1. Declaration of anonymous functions:

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

    1. Call

Variable name (parameter)

8. Program Call

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

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

Properties of 1.window Objects

Name

Description

History

Information about the URL that the customer has visited

Location

Information about the current URL

Screen

Information about the screen and display performance of the client

Weindow objects commonly used methods: Prompt () confirm (); settimeout (); SetInterval ();

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

Window.parent.location

2.History objects

Methods: Back (), forward (), go ();

The 3.Location object provides the URL of the current page

Attribute: host hostname href

Method: Reload () replace ();

4.Document objects

Properties: The Referrer property determines whether it is accessed by hyperlinks, not by returning NULL

The object in the 10.javaScript,

Date object:

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

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

Math object:

Ceil (); the logarithm is rounded up, ceil (25.5) = 26;

Floor (); Floor (25.5) = 25;

Math.Round (25.5), after the original number plus 0.5 after the whole

11.Dom Overview (Document Object model)

Made up of coredom,xmldom,html dom;

12. Create an array

The declaration of variables in JS:

Var array name =new array (size);

    1. Declare and then assign the value fruit[0]= ""
    2. The declaration also assigns Var fruit=new Array ("Apple", "orange"), or var fruit=new array["Apple", "orange"];

Read 1. Read 2 with a For loop. Use for---in read

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

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

Drop-down List Select object:

  

13, style positioning aspects of styles

Left top position Z-index

Mouse scrolling Distance: scorlltop: longitudinal distance

Scorllleft: Transverse distance

Mouse scrolling Leave: onscorll

Mutual conversion of jquery objects and Dom objects

    1. jquery objects are converted to DOMD objects, 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);//Detect if the checkbox is selected

The corresponding DOM object is obtained by the Get (index) method

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

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

alert (txtname.checked);//Detect 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 use Obj.classname=classname;

Add class capacity to use Obj.innerhtml=<input/>

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

Add class capacity to use:obj.html=<input/>;

The five main selectors in Jqurey:

    1. Base selector (#. Label
    2. Hierarchy Selector (descendant > child + Adjacent ~ sibling)
    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");//integrated AddClass and Romoveclass

$ (this). Val ("");/Empty text content

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

In regular expressions

  

Some of the tips used in JS:

1. Use!! The operator converts a Boolean value that can be used for a variable!! Varable do the detection, as long as the value of the variable is: 0,null, "", Undefind or Nan will return false to True

Function account (Cash)
{
This.cash = cash;
This.hasmoney =!! Cash
}

2. Use + to convert strings to numbers, only string data, or return Nan

function Tonumber (strnum) {
return +strnum;
}

Applies to date () return timestamp number: +new date ();

3. In the circulation very big time the number first gives out, the 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"

Above this JavaScript knowledge point summary (Must see article) is the small series to share to everybody's content, hoped can give everybody a reference, also hoped that everybody supports the cloud habitat community.

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.