View Single Post
Old 10-15-2012, 01:19 PM   PM User | #2
devnull69
Senior Coder

 
Join Date: Dec 2010
Posts: 2,245
Thanks: 10
Thanked 531 Times in 525 Posts
devnull69 will become famous soon enough
The semicolon in Javascript is used to end a statement. So with the semicolon at the end of the if statement you are already closing the if statement. So no matter what the condition in the if statement is, the next line(s) will always be executed.

This is the correct syntax for a simple if statement (one statement)
Code:
if(condition)
   statement;
This is the correct syntax for an if statement that should include more than one statement
Code:
if(condition) {
   statement1;
   statement2;
   ...
}
devnull69 is offline   Reply With Quote