JavaScript functions, Events

Source: Internet
Author: User
Tags mathematical functions

1. Functions
String functions

var s=new string ();

var ss= "Hello World";

var sss= "" HELLO, World ";

Alert (Ss.tolowercase ());--Convert to lowercase

Alert (Sss.touppercase ());--Convert to uppercase

Alert (SS.SUBSTR (2,3));--intercept string, starting at index 2, intercept 3 character length, not write the following number is truncated to the last

Alert (ss.substring (2,3));--intercepts a string from the 2nd position to the 3rd position

Sss.splite (",");--separates the string according to the specified character

Ss.length property, String length

Ss.indexof ("World");---Find the first occurrence of world in a string, return 1

Ss.lastindexof ("O");--Find the last occurrence of the position in the string

Time-Date function

var d=new date ();--Current time

var dd=new date (1999,3,2);--Define Time

Dd.getfullyear ();--Take the year

Dd.getmonth ();--Take the month, take out the 1 less

Dd.getdate ();--Date taken

Dd.getday ();--Take the day of the week

...

Dd.setfullyear ();--set year, set month note +1

Mathematical functions

Math.ceil ();--Take the upper limit

Math.floor ();--Take the lower limit

Math.sqrt ();--Open square

Math.Round ();--Rounding

Math.random ();--random number, 0-1

2. All Events
onclick--Click events
ondblclick--Double-click event

onmouseover--Mouse Move in
onmouseout--Mouse Removal

onfocus--Get Focus
onblur--loses focus

onkeyup--trigger when the button is lifted

window.onload--triggered when the button is pressed

window.onresize--Trigger when size changes

window.onload--page load-out trigger


3. Supplement


Block Event bubbling:
Window.event? window.event.cancelBubble = True:e.stoppropagation ();

JavaScript functions, Events

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.