JS Common Type Event

Source: Internet
Author: User

Common types:
1. Mathematics:
Math.ceil (): Number of ceilings
Math.floor (): Number of floors
Math.Round (): Rounding takes an integer
Math.random (): Generates a random number between 0-1

2. Date and Time:
var s = new Date ();
var s = new Date (1999,7,23);
Function:
getFullYear ():
GetMonth ():
GetDate (): Get Day
GetHours ()
Getminutes ()
Getseconds ()
GetDay (): Get Week
setFullYear (Year,month,day)
Sethours (HOUR,MINUTE,SECOND,MS)
toLocaleDateString (): Convert to local datetime format string

3. String
Length: The lengths of the strings
toLowerCase ()
toUpperCase ()

Compresses both spaces in the string.
function Trim (m) {
while ((m.length>0) && (m.charat (0) = = "))
m = m.substring (1, m.length);
while ((m.length>0) && (M.charat (m.length-1) = = "))
m = m.substring (0, m.length-1);
return m;
}

IndexOf ("substring"): The first occurrence of a position
LastIndexOf ("substring"): Last occurrence of position
The above two methods, if the parent string does not contain substrings, returns-1

substr ("Start position", "intercept Length")
SUBSTRING ("Start position", "End position")

Event: (Event source, event data, event handler)
One, the most commonly used mouse events
OnClick: The code to execute when the mouse is clicked.
OnDblClick: The code to execute when the mouse double-clicks.
onMouseOver: The code to execute when the mouse moves over the element.

onMouseOut: The code to execute when the mouse leaves the element.
< example > Light bar effect.
OnMouseDown
OnMouseUp
< example > Use these two events to make a simulated button with span.

<script>function  Dodown (dd) {    dd.style.bordercolor= "black";    Dd.style.backgroundcolor= "Green";    dd.style.margin= "10px 0px 0px 10px"    }    function  Doup (dd) {    dd.style.bordercolor= "red";    Dd.style.backgroundcolor= "#9c9";    dd.style.margin= "0px 0px 0px 0px"    }</script>

Post-click Effects:

Case Light Bar Effect

<body><table width= "border=" 1 "> <tr style=" padding:0px; Color:rgb (255, 0, 0); line-height:1.5!important; " > onmouseover= "Show (This)" onmouseout= "Done" > &LT;TD >&nbsp;</td> <td>&nbsp;< /TD> <td>&nbsp;</td> </tr> <tr onmouseover= "Show (This)" onmouseout= "Done" > & lt;td>&nbsp;</td> <td>&nbsp;</td> <td>&nbsp;</td> </tr> <tr Style= "padding:0px; Color:rgb (255, 0, 0); line-height:1.5!important; " > onmouseover= "Show (This)" onmouseout= "Done" > <td>&nbsp;</td> <td>&nbsp;< /TD> <td>&nbsp;</td> </tr> <tr onmouseover= "Show (This)" onmouseout= "Done" > & lt;td>&nbsp;</td> <td>&nbsp;</td> <td>&nbsp;</td> </tr> <tr Style= "padding:0px; Color:rgb (255, 0, 0); line-height:1.5!important; " > onmouseover= "Show (This)" onmouseout= "Done" > <td>&nbsp;</td> <td>&nbsp;< /td> <td>&nbsp;</td> </tr></table></body>

Case: Scratch Music

<style type= "text/css" >.wai{border:2px Ridge #F00;    width:128px;height:128px;margin:10px;    Float:left;    position:relative;        left:70px}. Nei {background-color: #F00;        WIDTH:128PX;HEIGHT:128PX} #btn {float:left;        width:100%;        Text-align:center;            } #main {width:900px;            Margin:auto; } </style><script language= "JavaScript" >var num=0;function Show (DD) {dd.style.display= "none"        ;    var s=dd.parentnode.getattribute ("haha"),/****** previous query *****/if (s== "1") {alert ("Congratulations winning"); Window.location.reload ();/******* winning auto reset ******/}num+=1;/** 10 times No automatic reset ***/if (num==10&&s!=1) {alert ("Come on, 10 bucks!").    ");    Window.location.reload ();}} </script>

Mobile Lottery

<style>.no1{margin:20px;    border:5px dashed #FF0000;        width:100%} #main {width:400px;        Margin:auto;        Text-align:center;        font-family: Chinese Xingkai;        font-size:50px} #begin {margin:20px;        Background: #03F;        BORDER:2PX solid red; PADDING:5PX} </style>

JS Common Type 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.