into JavaScript's study.

Source: Internet
Author: User

Learning JavaScript Today, JavaScript is a new description language that can be clamped into HTML files.

JavaScript can be used to respond to the user's needs events (such as the input of a form) without transmitting data back and forth from any network, so when a user enters a data, it does not pass to the server

Processing, and then passing back the process, and directly can be handled by the client application program.

Because yesterday I self-taught some, so the teacher said I do not sound difficult, but still apply, always make a little mistake, or less a parenthesis, or semicolon with the Chinese format,

Cause there is always no effect, or should be more practice, attached to the teacher today to explain the content:

1, three kinds of JS introduction mode
A), <input type= "button" value= "click event" onclick= "document.write (' Hello word! ') ' >
b), <script type= "Text/javascript" >
document.write (' Hello word! ‘)
</script>
c), <script type= "Text/javascript" src= "Js/index.js" ></script>
Note: External reference path to write to
Single double quotes: quotation marks cannot use the same quotation marks

2. Three kinds of pop-up window alter confirm prompt
3. Two types of annotation//single-line comment/* Multiline comment */
4. Define variable var variable name = variable value;
var variable name;
Variable name = variable value;
Note: All are semicolon ended * * * *
5, more than 90 excellent, more than 80 good, more than 60 pass 60 fail
6. If format
if (condition 1) {
Execution of the statement;
}else if (condition 2) {

}
Note: If...else If this is an if
if () {}
if () {}
This is a two if
7. Complete expression on both sides of the logical operator
8, all the symbols in the code are in English state
9. Switch syntax
Switch (variable) {
Case ' specific value ':
Code to execute
Break
Case ' specific value ':
Code to execute
Break
...
}
Example 1:1, the input positive integer n, to seek 1-n and.

var a=prompt ("Please enter a number");
var sum=0;
if (IsNaN (a)) {
document.write ("You are not entering a number")
}else{
for (Var i=0;i<=a;i++) {
Sum=sum+i;
}
}
document.write (sum);
document.write ("<br/>");

Example 2: Enter the score to determine whether the pass, if more than 80 points output "you learn good, worthy of praise!" ", if the output between 50-60 points is a little bit, and then add strength", if less than 50 output "hard work, do not lazy!" ”

var b=prompt ("Please enter your score");
if (b>80) {document.write ("You learn well, deserve praise!") ")}
else if (b>50&&b<60) {document.write ("Just a little bit, and then the Harder")}
else if (b<50) {document.write ("hard work, don't be lazy!") ")}

Example 3:100 staircase, 0-49 knots equal to the number of nodes 50 (including 50) Each section 10 points the number of input sections to score

Num: Number of sections
NUM1: Number of knots-49
Sum Total
if (num<=49) {
for (i <= num)
}else{
NUM1 = num = 49;
for (i <=) {sum1 = SUM1 + i} score sum1
for (I<NUM1) {SUM2 = SUM2 + 10} score sum2
sum = sum1 + sum2
}

Learning to go into JavaScript

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.