Have some free time recently, want to learn the front-end things on the plan to start with JavaScript. While reading a book, jot down notes.
JavaScript built-in objects
Hide and show:
Syntax: Object.style.display = value
Note: object is an element that gets an element object, such as a document.getElementById ("id"). Value:none (Display), Block (hidden).
Date Day object:
Description: A Date object can store any date and can be accurate to the number of milliseconds (1/1000 seconds).
650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>650 "this.width=650;" src= "http ://s3.51cto.com/wyfs02/m02/5b/85/wkiom1uknv3dgokmaahgydf182k413.jpg "title=" Image.png "alt=" Wkiom1uknv3dgokmaahgydf182k413.jpg "/>
String object:
CharAt ()
Description: Method returns the character at the specified position. The returned character is a string of length 1.
Syntax: Stringobject.charat (Index)
Attention:
1. The subscript for the first character in a string is 0. The subscript for the last character is the string length minus one (string.length-1).
2. If the parameter index is not between 0 and String.length-1, the method returns an empty string.
IndexOf ():
Description: The method returns the position of the first occurrence of a specified string value in a string.
Syntax: stringobject.indexof (substring, startpos).
Attention:
1. The method will retrieve the string stringobject from beginning to end to see if it contains substring substring.
2. Optional parameters, starting from the startpos position of the stringobject to find substring, if no this parameter will be found from the beginning of the Stringobject.
3. If a substring is found, the position of the first occurrence of the substring is returned.
Split ():
Description: Method splits a string into an array of strings and returns this array.
Syntax: Stringobject.split (separator (required), limit (optional: Number of splits, returned array will not be redundant for this parameter)).
Attention:
If an empty string ("") is used as a separator, then each character in the string is split between them.
SUBSTRING ():
Description: A character used to extract a string intermediary between two specified subscripts.
Syntax: stringobject.substring (Starpos,stoppos).
Attention:
1. The returned content is all characters from start (the character containing the start position) to Stop-1, whose length is stop minus start.
2. If the parameter start is equal to stop, then the method returns an empty string (that is, a string of length 0).
3. If start is larger than stop, the method will exchange the two parameters before extracting the substring.
SUBSTR ():
Description: Extracts a specified number of strings from a string, starting at the startpos position.
Syntax: Stringobject.substr (startpos,length);
Attention:
If the parameter startpos is a negative number, the position is calculated from the end of the string. That is,-1 refers to the last character in the string, 2 refers to the second-lowest character, and so on. If Startpos is negative and the absolute value is greater than the string length, Startpos is 0.
Array object:
An array object is a collection of objects that can be of different types. Each member object of an array has a "subscript" that represents its position in the array, which is zero-based
Method of array Definition:
1. Defines an empty array:
var array name = new Array ();
2. Define an array of n empty elements when specified:
var array name =new array (n);
3. When defining an array, initialize the data directly:
var array name = [< element 1>, < element 2>, < element 3>...];
Array properties:
Length usage:< Array Object >.length; return: The length of the array, which is the number of elements in the array. It equals the subscript of the last element in the array plus one.
650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>650 "this.width=650;" src= "http ://s3.51cto.com/wyfs02/m01/5b/80/wkiol1uknteiialkaaie7ptdpby964.jpg "title=" Image.png "alt=" Wkiol1uknteiialkaaie7ptdpby964.jpg "/>
Second, the Math object:
Description: The Math object is an intrinsic object that you can call all of its properties and methods without creating it and directly using Math as an object. This is the difference between it and the Date,string object.
650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>650 "this.width=650;" src= "http ://s3.51cto.com/wyfs02/m02/5b/85/wkiom1ukngctvxccaajdkswhgxg178.jpg "title=" Image.png "alt=" Wkiom1ukngctvxccaajdkswhgxg178.jpg "/>
Third, Windows objects:
Description: The Window object is the core of the BOM, and the Window object refers to the current browser window.
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/5B/84/wKiom1UKkruCH9nWAANJZ43k_Xs213.jpg "title=" Image.png "alt=" Wkiom1ukkruch9nwaanjz43k_xs213.jpg "/>
Timer setinterval ():
Description: Executes code at the specified time after the page is loaded at execution time.
Syntax: setinterval (code, interaction time);
1. Code: The function to invoke or the code string to execute.
2. Interaction time: The time interval between periodic execution or invocation of an expression, in milliseconds (1s=1000ms).
Return value: A value that can be passed to clearinterval () to suppress periodic execution of "code."
Cancel Timer clearinterval ():
Description: The Clearinterval () method cancels the interaction time set by SetInterval ().
Syntax: Clearinterval (id_of_setinterval).
Parameter description: Id_of_setinterval: The ID value returned by setinterval ().
Timer settimeout ():
Description: SetTimeout () timer, after loading after delay for a specified time, to execute an expression once, only once.
Syntax: setTimeout (code, delay time);
Parameter description:
1. The function to invoke or the code string to execute.
2. Delay time: The amount of time, in milliseconds (1s=1000ms), to wait before executing the code.
Cancel Timer cleartimeout ():
Similar to Clearinterval ().
Four, Location object:
Description: Location is used to get or set the URL of the form and can be used to resolve URLs.
Syntax: location. [Properties | method].
650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>650 "this.width=650;" src= "http ://s3.51cto.com/wyfs02/m02/5b/7f/wkiol1ukla_y316vaagmdcg1rqi765.jpg "title=" Image.png "alt=" wKioL1UKlA_ Y316vaagmdcg1rqi765.jpg "/>
Location Object method:
650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>650 "this.width=650;" src= "http ://s3.51cto.com/wyfs02/m01/5b/80/wkiol1ukngjysrqeaacgt7pmgbi048.jpg "title=" Image.png "alt=" Wkiol1ukngjysrqeaacgt7pmgbi048.jpg "/>
V. Navigator objects
Description: The Navigator object contains information about the browser and is typically used to detect the version of the browser and operating system.
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/5B/80/wKioL1UKnjPQbbPpAAEYrNp1bdc764.jpg "title=" Image.png "alt=" Wkiol1uknjpqbbppaaeyrnp1bdc764.jpg "/>
VI. DOM Object
To access the sibling node:
1. The NextSibling property returns the node immediately following a node (at the same tree level).
Syntax: nodeobject.nextsibling
Description: If there is no this node, the property returns NULL.
2. The PreviousSibling property returns the node immediately before a node (at the same tree level).
Syntax: nodeobject.previoussibling
Description: If there is no this node, the property returns NULL.
Note: Two properties get the node. Internet Explorer ignores white-space text nodes (for example, newline symbols) that are generated between nodes, and other browsers do not ignore them.
Insert Node appendchild ():
Description: Adds a new child node after the list of the last child nodes of the specified node.
Syntax: AppendChild (newnode)
Parameter: NewNode: Specifies the appended node.
Insert Node InsertBefore ():
The InsertBefore () method inserts a new child node before the existing child node.
Syntax: InsertBefore (Newnode,node);
Parameter: NewNode: The new node to be inserted. Node: Specifies that nodes are inserted before this node.
Delete Node removechild ():
The RemoveChild () method removes a node from the list of child nodes. If the deletion succeeds, this method returns the node that was deleted, such as failure, and returns NULL.
Syntax: Nodeobject.removechild (node)
Parameters: node: required to specify which nodes need to be deleted
Replace element node ReplaceChild ():
ReplaceChild implements the substitution of child nodes (objects). Returns a reference to the object being replaced.
Syntax: Node.replacechild (newnode,oldnew)
Parameters:
NewNode: Required to replace the Oldnew object.
Oldnew: Required, object replaced by NewNode.
To create an element node createelement:
The CreateElement () method creates an element node. This method can return an Element object.
Syntax: document.createelement (tagName)
Parameter: TagName: String value, which is used to indicate the type of element being created.
Note: To be used in conjunction with the appendchild () or InsertBefore () method, the element is displayed in the page.
To create a text node createTextNode:
The createTextNode () method creates a new text node and returns the newly created textual node.
Grammar:
document.createTextNode (data)
Parameters:
Data: A string value that specifies the text for this node.
This article is from the "Bad Idea enough" blog, please be sure to keep this source http://mjldhc.blog.51cto.com/8569563/1622316
Javascrip Study Notes