菜鸟菜鸟菜菜鸟

if语句

语法:

if(condition) statement1 else statement2

当condition为true时,执行statement1语句,否则则执行statement2语句

例如:

if(i>25){

 alert("Greater than 25");
}else{
 alert("Less than or equal to 25");

}

多个if语句

语法:

if(condition1) statement1 else if(condition2) statement2 else statement3

例如:

if(i>25){

 alert("Greater than 25");
}else if(i<0){
 alert("Less than 25");

}else{

 alert("Between 0 and 25,inclusive");

}

posted on 2016-09-12 20:25  菜鸟菜鸟菜菜鸟  阅读(198)  评论(0)    收藏  举报

导航