gpt4 book ai didi

javascript - 这与 $(document).ready() 有什么不同?

转载 作者:行者123 更新时间:2023-12-02 19:27:47 26 4
gpt4 key购买 nike

Possible Duplicate:
Is there a difference between $().ready() and $(document).ready()

我正在尝试为页面设置 jquery ui 选项卡,并且我使用了

$(document).ready(function(){
$('#tabs').tabs();
});

这不起作用。所以我检查了他们的示例,发现现在可以使用不同的语法

$(function(){
$('#tabs').tabs();
});

这两种语法有什么区别?

最佳答案

它们是等效的。 http://api.jquery.com/ready/

The .ready() method is typically used with an anonymous function:

$(document).ready(function() {
// Handler for .ready() called.
});

Which is equivalent to calling:

$(function() {  
// Handler for .ready() called.
});

If .ready() is called after the DOM has been initialized, the new handler passed in will be executed immediately.

关于javascript - 这与 $(document).ready() 有什么不同?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11855450/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com