17
Jul/09
1

$(document).ready() Shortcut

When writing jquery you almost always put your code within a ready block:

$(document).ready(function(){
    // Code...
});

And I always forget the exact syntax. I just found that jQuery has a shortcut:

$(function(){
    // Code...
});

Much better!

Comments (1) Trackbacks (0)
  1. Windigo
    3:31 pm on June 7th, 2010

    I heard about this in a jQuery presentation, but the presenter never posted the code. This was just what I was looking for – thanks for the great tip!!!

Leave a comment

No trackbacks yet.