$(document).ready()的简写。
允许你绑定一个在DOM文档载入完成后执行的函数。这个函数的作用如同$(document).ready()一样,只不过用这个函数时,需要把页面中所有需要在 DOM 加载完成时执行的$()操作符都包装到其中来。从技术上来说,这个函数是可链接的--但真正以这种方式链接的情况并不多。
你可以在一个页面中使用任意多个$(document).ready事件。
参考 ready(Function) 获取更多 ready 事件的信息。A shorthand for
$(document).ready().
Allows 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. While this function is, technically, chainable - there really isn't
much use for chaining against it.
You can have as many $(document).ready events on your page as you like.
See ready(Function) for details about the ready event.
返回值
jQuery
参数
callback (Function) : 当DOM加载完成后要执行的函数
示例
当DOM加载完成后,执行其中的函数。
jQuery 代码:
$(function(){
// Document is ready
});
// Document is ready
});
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 代码:
jQuery(function($) {
// Your code using failsafe $ alias here...
});
// Your code using failsafe $ alias here...
});
本文介绍了一个简写版本的$(document).ready()函数,该函数用于绑定一个在DOM文档加载完成后执行的函数。它的工作原理与$(document).ready()相同,但在实际应用中通常用于包装依赖于DOM就绪的所有$()操作。本文还提供了如何使用此简写形式的示例。
1031

被折叠的 条评论
为什么被折叠?



