亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

JavaScript If...Else ?

???

????? ??? ??? ? ??? ??? ?? ?? ??? ??? ???? ???. ???? ???? ???? ? ??? ??? ? ????.

JavaScript??? ??? ?? ???? ??? ? ????.

if ? - ??? ??? true? ?? ??? ????? ? ?? ?????.

if...else ? - ??? true? ? ??? ????, ??? ? ?????. ??? false? ? ?? ??

if...else if....else ? - ??? ?? ?? ?? ? ??? ????? ? ?? ?????.

switch ? - ?? ?? ?? ? ??? ????? ? ?? ?????. ,


if ?? ?????.

??:

if (expr){
?
}

? ??? expr ?? true? ?? {statement}? ??? ?????.

<!DOCTYPE html>
<html>
<head> 
<meta charset="utf-8"> 
<title>php中文網(wǎng)(php.cn)</title> 
    <script type="text/javascript">
        var x = 3;
        var y = 1;
        if (x>y)
        alert("x 大于 y");
      </script>
</head>
<body>
</body>
</html>


if…else

??:

if (expr) {
statement1
} else {
statement2
}

??? expr ????, ???1? ?????. ??? ??? ???2? ??????.

<!DOCTYPE html>
<html>
<head> 
<meta charset="utf-8"> 
<title>php中文網(wǎng)(php.cn)</title> 
    <script type="text/javascript">
        var x = 1;
        var y = 3;
        if (x>y){
        alert("x大于y");
        } else {
        alert("x小于等于y");
        }
      </script>
</head>
<body>
</body>
</html>


if...else if...else

??:

if (expr1){
?statement1
} else if (expr2) {

} else {
statement3
}

? ??? expr1? true? ???? statement1? ????, ??? ??? expr2? true? ?? expr2? ????, expr2? true? ???? statement3? ???? ?????.

<!DOCTYPE html>
<html>
<head> 
<meta charset="utf-8"> 
<title>php中文網(wǎng)(php.cn)</title> 
    <script type="text/javascript">
        var x = 3;
        var y = 3;
        if (x>y) {
        alert("x大于y");
        } else if (x<y) {
        alert("x小于y");
        } else {
        alert("x等于y");
        }
      </script>
</head>
<body>
</body>
</html>


???? ??
||
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>php中文網(wǎng)(php.cn)</title> <script type="text/javascript"> var age = 3; if (age >= 18) { alert('adult'); } else if (age >= 6) { alert('teenager'); } else { alert('kid'); } </script> </head> <body> </body> </html>