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

JavaScript中的if條件判斷語句

if條件判斷語句:

#條件成立,執(zhí)行什麼程式碼;條件不成立,執(zhí)行什麼程式碼


結(jié)構(gòu)一:只判斷真(true),條件為假,什麼都不做

if(條件判斷:判斷結(jié)果是一個布林值)

{

條件為真(true),執(zhí)行的程式碼

}


結(jié)構(gòu)二:既判斷真,也判斷假

if (條件判斷)

{

條件為真,執(zhí)行的程式碼

}else

{

條件為假,執(zhí)行的程式碼

}


#結(jié)構(gòu)三:多條件判斷

#if(條件1)

{

程式碼1;

}else if(條件2)

{

程式碼2;

}else if(條件3)

{

#程式碼3;

##}else

{

如果以上條件都不成立,則執(zhí)行程式碼;

}

注意:雖然有多個條件,但各條件之間是「或」的關(guān)係。每時每刻,只能有一個條件成立,不能同時滿足多個條件。

<!DOCTYPE HTML>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <title>php.cn</title>
        <script>
        //給一個成績
        var score=89;
        //判斷成績所屬級別
        if(score<60){
            document.write("對不起,沒有及格");
        }else if (score>=60&&score<70){
            document.write("剛好及格");
        }else if(score>=70&&score<80){
            document.write("成績良好");
        }else if(score>=80&&score<90){
            document.write("成績優(yōu)秀");
        }else if(score>=90&&score<100){
            document.write("試卷這么難,這樣的成績簡直逆天");
        }else{
            document.write("對不起,你的成績超出系統(tǒng)判斷范圍,請重新輸入");
        }
        
        </script>
    </head>
    <body>
    </body>
</html>


#

繼續(xù)學(xué)習(xí)
||
<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>php.cn</title> <script> //給一個成績 var score=89; //判斷成績所屬級別 if(score<60){ document.write("對不起,沒有及格"); }else if (score>=60&&score<70){ document.write("剛好及格"); }else if(score>=70&&score<80){ document.write("成績良好"); }else if(score>=80&&score<90){ document.write("成績優(yōu)秀"); }else if(score>=90&&score<100){ document.write("試卷這么難,這樣的成績簡直逆天"); }else{ document.write("對不起,你的成績超出系統(tǒng)判斷范圍,請重新輸入"); } </script> </head> <body> </body> </html>