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");
}
浙公网安备 33010602011771号