With JavaScript, jQuery or any other programming language, it is of utmost importance to be sure you are coding correctly. There are a few very basic rules that you must follow for your program to run, then there are other approaches that are not required, but should be applied to save coding time, debugging time and possible errors in the result of running the program.


♦ Use the correct spelling and capitalization

JavaScript and jQuery are case sensitive. This means that if you define a variable with an uppercase letter, you must use the exact same uppercase letter everytime you use that variable.

The same goes for commands and methods - they must be spelled correctly and are case sensitive.


♦ Use the correct style of brackets

Some things require square brackets [ ... ], others curly brackets { ... }, others parentheses ( ... ). You must use the right style of brackets, or the script will not run properly.


♦ Close your brackets properly

Every open bracket [  {   ( requires a closing )  }  ]. Brackets can be nested inside of each other, so this can be confusing. Make use of a good text editor - where it highlights the closing bracket when you highlight the opening bracket. If the closing bracket does not appear where it should in the code - then you have a problem somewhere with matching brackets.


♦ Don't mix your quotation marks

In most cases you can use double quotes " ... " or single quotes ' ... ' to enclose strings or other information like the selector. You can not have a double quote closing a single quote or vice versa. It is best to stick with one way of doing it as much as possible. If you need to enclose quotation marks inside other quotation marks, you must switch to the other variety for the inner set of quotation marks.