当DOM完成加载的时候绑定一个要执行的函数。version added: 1.0
jQuery( callback )
callback 当DOM完成加载的时候绑定的函数
允许你绑定一个在DOM文档载入完成后执行的函数。这个函数的作用如同$(document).ready()一样,只不过用这个函数时,需要把页面中所有需要在 DOM 加载完成时执行的$()操作符都包装到其中来。从技术上来说,这个函数是可链接的--但真正以这种方式链接的情况并不多。
例子:
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...
});