$(callback)和$(document).ready(function)之间的区别? [英] Difference between $(callback) and $(document).ready(function)?
问题描述
在jQuery网站上, $(callback)
的描述是它的行为与 $(document).ready(function)
但是示例显示了两种语法之间的一些差异。所以我想知道,有没有人知道两者之间的区别是什么?
以下所有三种语法都是等效的:
- $(document).ready(handler)
- $()。ready(handler) $ b
- $(处理程序)
直接从:http://api.jquery.com/ready/
我认为你对示例 jQuery(function($){...});
这只是一种调用 $ / code>,没有
$
冲突。
IE。
//这里`$`被另一个库使用
jQuery(function($){
//这里`$` jQuery
});
On the jQuery site, the description for $(callback)
was that it behaves the same as $(document).ready(function)
but then the examples showed some differences between the two syntaxes. So I was wondering, does anyone know exactly what the differences between the two are?
There are no differences, and the docs don't show any difference:
All three of the following syntaxes are equivalent:
- $(document).ready(handler)
- $().ready(handler) (this is not recommended)
- $(handler)
Straight from: http://api.jquery.com/ready/
I think you are confused by the example showing jQuery(function($){ ... });
Which is just a way of calling $(handler)
, with no $
conflict.
IE.
// Here `$` is used by another library
jQuery(function($){
// Here `$` refers to jQuery
});
这篇关于$(callback)和$(document).ready(function)之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!