You should always start your jQuery using the ready() function. The handler passed to .ready() function is guaranteed to be executed after the DOM is ready.
There are a few ways to start your jQuery function, but all are equivalent:
$(document).ready(function() { // Do some magic }); $().ready(function() { // A bit quicker to write }); $(function() { // Nice shorthand that I prefer to use });