One, the operation of the string
1. Turn Capital:
S.tolowercase ();
2. Turn Capital:
S.touppercase ();
3, the interception of the string:
S.SUBSTR (3,4); -Intercept from index 3 and intercept 4 bits. The index starts at 0.
4. Detach the string as specified:
S.split (","); Enclose the specified character in quotation marks. The return is an array.
5. String Length:
S.length;
6, the index of one character in the string:
S.indexof ("World"); World the first occurrence of the position in the string, the index is returned, if no 1 is returned.
7, o the last occurrence of the string in the position:
S.lastindexof ("O");
Ii. operation of Time and date
1. Current Time:
var d =new Date ();
2. Define a time:
var d =new Date(2017,03,02); February 2, 2017.
3. Year of Acquisition: D.getfullyear (); Get month: D.getmonth (); 1 less months to take out. Get Day: D.getdate (); Get Day of the Week: D.getday ();
Acquisition Hours: D.gethours (); Get minutes: D.getminutes (); Get seconds: d.getseconds (); Set year: D.setfullyear (); Add 1 when setting the month.
Third, the operation of mathematical functions:
1, Math.ceil (); Take the upper limit
2, Math.floor (); Lower limit
3, math.sqrt (); Open Square
4, Math.Round (); Rounded
5, Math.random (); Random number, between 0-1.
Iv. Events
OnClick Mouse Single Trigger
OnDblClick Mouse double-click Trigger
onmouseover Mouse Move-in trigger
onmouseout Mouse move out Trigger
OnMouseMove Mouse on top move trigger
onchange content Change Trigger
onblur Loss of Focus trigger (focus refers to the cursor position)
Onfocus Get intersection Trigger
OnKeyDown Press the button to trigger
onkeyup Lift button trigger can be displayed synchronously
All content of Window.onload browser is triggered after play, only one onload event is allowed on a page, not recommended
Window.onresize Browser size change is triggered
Gets the current client width, height:
Window.onresize=fuction () {
var wid =document.documentelement.clientwidth;
var hei =document.documentelement.clientheight;
}
Block event bubbling: window.event? window.event.cancelBubble = True:e.stoppropagation ();
JS for strings, time dates, operation of mathematical functions, and use of common events (organization event bubbling)