您的位置:首页 > 其它

$(document).ready()的简短写法$()——设置当DOM完成加载的时候绑定的函数

2012-02-13 22:31 453 查看
jQuery( callback ) 返回: jQuery

当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...

});
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐