Summary of new javascript syntax

Source: Internet
Author: User

What new students often learn ~
<Script language = "javascript"> alert ('badwolf test! '); </Script> // prompt
<Script language = "javascript"> alert ('haha! '); </Script> // prompt
<Script language = "javascript"> alert (new Date (); </script> // read system time
<A href = "javascript: alert (new Date ();"> www.winshell.cn </a> // click to connect to the js running display time
<Input type = "button" onClick = "alert (new Date ()" value = "Click here"> // click Submit to display the js running time.
********************** For loop ************** *************
<Script>
Var badwolf_x = "";
For (var x = 1; x <= 100; x ++)
{
Badwolf_x = badwolf_x + "x =" + x;
}
Alert (badwolf_x );
</Script>

**************** *************
<Script>
Function get_sum ()
{
Var x = parseFloat (document. jisuanqi. no1.value );
Var y = parseFloat (document. jisuanqi. no2.value );
Var sum = x + y;
Alert (sum );
// Return sum;
}
</Script>
<Form name = "jisuanqi" action = "#">
<Input type = "text" name = "no1" value = "Enter the first number">
<Lable> + </lable>
<Input type = "text" name = "no2" value = "enter the second number">
<Input type = "button" value = "calculation" onclick = "get_sum ()">
</Form>
* ********************* If/else displays comments based on the score ********** *****
<Html>
<Head>
<Title> if/else displays comments based on the score </title>
</Head>
<Script>
Function dd ()
{
Var aa = document. form1.chengji. value;
If (aa <= 100 & aa> 90)
{
Alert ("excellent performance ");
}
Else if (aa <= 90 & aa> 75)
{
Alert ("Medium score ");
}
Else if (aa <= 75 & aa> = 60)
{
Alert ("pass ");
}
Else if (aa <60 & aa> = 0)
{
Alert ("fail ");
}
Else
{
Alert ("you are stupid ~~~!! Did you enter the score ???? ");
}
}
</Script>
<Body>
<Form name = "form1" action = "#">
<Lable> enter your score <lable> <input type = "text" name = "chengji"> <input type = "button" value = "to get comments !! "Onclick =" dd () ">
</Form>
</Body>
</Html>
***************
<Script>
Var x = 10;
Var y =-4;
If (x> 20)
{
If (y> 0)
{
Alert (x + y );
}
Else
{
Alert (x-y );
}
}
Else
{
Alert ('pipi ');
}
</Script>

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.