JavaScript consists of:
1) ECMAscript Specifies the syntax part of JS: The usual functions of string, array and time
String: Create string, with length
//string Use definition 1: var str= "ADSAFDSAFD"; Mode 2: Use the String Object var str2=new string ("Sadsaq"); //The length of the word A: var strlength=str2.length; document.write (strlength);
//Determines whether a string contains a specified string: var stremail= "[email protected]"; var check= "@"; var res=stremail.indexof (check); document.write (res+ "<br/>");
String intercept//start intercept from the index of the parameter, and intercept to the end of the string var newstr=stremail.substring (5); document.write (newstr+ "<br/>");
//intercept from the position of parameter 1, intercept to parameter 2, but does not contain parameter 2 var nere=st Remail.substring (5.8); document.write (nere+ " < BR Span style= "COLOR: #0000ff" >/> //from the position of the parameter 1, the parameter 2 is to intercept a few var ste=stremail.substr (5,3); document.write (ste+ " < BR />
//Case conversion//string with all words converted to uppercase var str5=stremail.touppercase (); document.write (str5+ "<br/>"); //Convert to lowercase var str6=str5.tolowercase (); document.write (STR6);
Array:
//Array declaration Method 1: Literal way var arystr=["Edison Chen", "Daniel Wu", "Peng"; Alert (arystr[1]); //Array Declaration Method 2: Constructor mode var arystu2=new Array (); arystu2[0]= "Huang Xiaoming"; Arystu2[1]= "Song"; Alert (arystu2[0]); for (Var i=0;i<arystr. length;i++) { document.write (arystr[i]+ "<br />") }//Enhanced for: The loop variable holds the index for (var i in arystr) { document.write (arystr[i]+ " < BR /> ") }
var arystu=["Daniel Wu", "Edison Chen", "Peng"; Adds an element Arystu.push ("Deng Chao") to the end of the array; Printary (Arystu); //Delete the element at the end of the array Arystu.pop (); Printary (Arystu); //Start adding elements to an array Arystu.unshift ("Luhan"); Printary (Arystu); //delete array start element Arystu.shift (); Printary (Arystu);
//Delete the element at the end of the array Arystu.pop (); Printary (Arystu); //Start adding elements to an array Arystu.unshift ("* *"); Printary (Arystu); //delete array start element Arystu.shift (); Printary (Arystu);
//Link The elements of an array into a string var str=arystu.join (); alert (str); //array elements inverted Arystu.reverse (); Printary (Arystu);
Role:
1. Form Verification Focus
2. Dynamic Effect:
Which line the mouse moves to, which line is highlighted
Dynamically create, add, and delete label highlights
3. Parsing of JSON data
2) BOM Programming Browser object model, control the function of the browser:
1. How to get labels-focus
ID class name Tag hierarchy relationship
2. Change the style
Label object. style. style = "style value";
The label object. Classname= "class selector";
3. Dynamically create, add, delete tags
Dynamically create an LI tag
Dynamically creating row, column Table clone nodes
The assignment and value of the label:
Form Label: Label object. value= ""; --Assignment value :. Value (); Non-form Label: Label object. Innerhtml/innertext
1. Time function
var time=new Date (); Time.get gets various attributes (month is 0-11, week is 0-6, 0 is Sunday)
SetInterval ("Get Time Function", milliseconds) can call a function or evaluate an expression by a specified period (in milliseconds)
Javascript:dom, String, array, time