Yes you can, but you can also use AND operator :
if(true && true){}
else{}
//Will go in the if
if(true && false){}
else{}
//Will go in the else
If you want multiple if :
if(true){
if(true){}
}else{
if(true){
}else if(true){
}
}
Note that if you do a nested if :
if(true){
if(false){}
}else{
}
If the second condition is false, the else statement will not be proc.
Play with this fiddle : http://jsfiddle.net/dBwU3/
Just change the value in the if
to false
or true
to see what happen.
0
solved Two if statements?