javascript--Grammar 21, experience
When judging, keep the left side constant.
Switch in Java only supports four types, JavaScript is a weak type, and all are supported.
Display method:
x=// alert ("+x");/ /write data directly to the current page. document.write ("x=" +x+ "<br/>");
Second, the Code
1<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01//en" "HTTP://WWW.W3.ORG/TR/HTML4/STRICT.DTD" >234<meta http-equiv= "Content-type" content= "text/html; CHARSET=GBK ">5<title>untitled document</title>67<body>8<script type= "Text/javascript" >9 /*Ten * Statement: One * 1, sequential structure. A * - * 2, judging the structure. - * Representative statement: If. the * 3, select structure. - * Switch - * 4, loop structure. - * while do and for + * 5, other statements. - * Break: Jump out of the selection and jump out of the loop. + * Continue: Used for looping statements, ending this cycle to continue the next cycle. A */ at - //alert ("ABC1"); - //alert ("ABC2"); - - - // ------------------------------------------------ in /* - var x = 3; to //if (x=4) {//note. + if (4==x) {//suggest to leave the constant on the left. Fix the code with an error. - alert ("yes"); the }else{ * alert ("no"); $ }Panax Notoginseng - the + if (x>1) A alert ("a"); the else if (x>2) + alert ("B"); - else if (x>3) $ alert ("C"); $ Else - alert ("D"); - the */ - Wuyi // ------------------------------------------------ the /* - //select structure. Wu var x = "abc"; - switch (x) { About $ Case "KK": - alert ("a"); - Break ; - Case "ABC": A alert ("B"); + Break ; the Default: - alert ("C"); $ break;//omitted. Because it's the last statement, and the curly braces are behind it. the } the */ the the - in //loop structure. the /* the var x = 1; About document.write ("<font color= ' Blue ' >");//color control, HTML content the While (X<10) the { the //Alert ("x=" +x); + //write the data directly to the current page. document.write ("x=" +x+ "<br/>"); the x + +;Bayi } the document.write ("</font>"); the - - For (var x=0; x<3; x + +) { the document.write ("x=" +x); the } the */ the - the /* the W:for (var x=0; x<3; x + +) {//label the For (var y=0; y<4; y++) {94 document.write ("x===" +x); the continue W; Jumps out of the current loop. the } the }98 */ About - 101</script>102 103 104 the 106</body>107javascript--Syntax 2--statement structure