有什么区别:
$(document).ready(function() {// Do something});
和
$(function() {//Do something});
在 jQuery 中?
最佳答案
如果我简单地尝试一下,它们是别名。它们是等价的。
注意
$(document).ready(function() {
})
$().ready(function() {
// this is not recommended
})
$(function() {
});
都是一样的。
<小时/>更多
jQuery 开发人员建议使用:
$(document).ready(function() {
});
为什么不推荐$().ready()
参见Why "$().ready(handler)" is not recommended?
关于jquery - jQuery 中的 $(document).ready(…) 和 $(function() {}) 有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10894777/