Wednesday, September 28, 2011

$(Function)

$(Function fn) returns jQuery
A shorthand for $(document).ready(), allowing you to bind a function to be executed when the DOM document has finished loading. This function behaves just like $(document).ready(), in that it should be used to wrap other $() operations on your page that depend on the DOM being ready to be operated on.

You can have as many $(document).ready events on your page as you like.

Example:
Executes the function when the DOM is ready to be used.

$(function(){
// Document is ready
});

Example:
Uses both the shortcut for $(document).ready() and the argument to write failsafe jQuery code
using the $ alias, without relying on the global alias.

jQuery(function($) {
// Your code using failsafe $ alias here...
});

No comments:

Post a Comment