Monday, November 25, 2013

Shortcut to "Document is ready" code in jQuery

When you want to execute some jQuery you normally encapsulate the code inside one of these:
$(document).ready(function () {
    // Code that executes when document is ready.
});
However, when looking around at examples in the API documentation, you'll sometimes see this which apparently is equivalent:
$(function() {
    // Code that executes when document is ready.
});

No comments:

Post a Comment