JS string time number function operation event

Source: Internet
Author: User

String manipulation

var s= "ABCDEFG"

S.tolowercase () Turn lowercase

S.touppercase () Turn capital

S.substring (2,5) index subscript starting from 0 intercept 5 bits starting from the 3rd

S.substr (2,5) Ibid.

Suppose s= "A,b,c,d,e,f,g"

S.split (', ') has commas separated by commas a string of several elements an element

For example:

1     var " a,b,c,d,e,f,g " ; 2     var ss = S.split (','); 3      for (var0; i < ss.length; i++) 4     {alert (ss[i]);}
View Code

S.length length

S.indexof ("World") find the first world where there is no return-1

Time-Date function

var d=new Date (); The current system time is seldom used because the user's computer time can be changed casually

var d=new date (1999,3,2) time format definition time is March 2, 1999

Get year D.getfullyear

Get Month D.getmonth ()

Get Day D.getdate ()

Get the day of the Week D.getday ()

Get hour Minute seconds d.gethours () d.getminutes () D.getseconds ()

Set year d.setfullyear ()

Mathematical functions

Go to Upper limit Math.ceil ()

Go to lower limit math.floor ()

Open Square math.sqrt ()

Rounding Math.Round ()

Random number Math.random () random number is between 0-1

To take a random number between 0-5

Math.ceil (5*math.random ())

Add a little bit of knowledge

S.match (REG) s represents a string of Reg representing a string of two matches equivalent to if in the S==reg

Event

OnClick Click Trigger

OnDblClick Double-click Trigger

onmouseover Move-in Trigger

onmouseout Move out Trigger

OnMouseMove Mouse on top move trigger

onchange content Change Trigger

Onblur Lose Focus Trigger

Onfocus Get Focus Trigger

onkeydown Button Press the trigger

onkeyup Button lift up trigger

onkeypress Release any letter key trigger but the system button is not recognized (for example: arrow function key)

JS string time number function operation event

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.