jQuery文档准备功能 [英] jQuery document ready function

查看:79
本文介绍了jQuery文档准备功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下jQuery片段的最终结果是否相同?

Are the end results of the following jQuery snippets identical?

代码段1:

$(function() { alert('test!'); });

代码段2:

$(document).ready(function() { alert('test!'); });

换句话说,$(function(){})只是$(document).ready(function() { });的简写吗?

In other words, is $(function(){}) just shorthand for $(document).ready(function() { });?

我问的原因是因为我们在使用jQuery和jQuery UI构建的小型应用程序中遇到了一些奇怪的问题.有时,通过单击按钮执行表单提交操作时,浏览器窗口将冻结.我们仍然可以使用基础的浏览器窗口(启动弹出窗口的窗口),直到我们在其中执行一些操作为止.用户只能通过强制关闭浏览器(很明显是Internet Explorer)才能继续.我们怀疑这与Acrobat PDF插件有关,但是我只是在这里检查所有角度,因为我发现了此问题似乎表现出类似的行为.

The reason I'm asking is because we're seeing some strange issues with a small application we've built using jQuery and jQuery UI. Occasionally, when performing a form submit action by clicking a button the browser window will just freeze. We can still use the underlying browser window (the one that launches the pop-up) until we perform some actions there. The users can only continue by force closing the browser (Internet Explorer, obviously). We suspect this is related to the Acrobat PDF plug-in, but I'm just checking all the angles here, because I found this issue which seems to exhibit similar behaviour.

推荐答案

是的,它们是等效的.请参阅此链接以获取参考 .ready()

Yes they're equivalent. See this link for reference .ready()

这篇关于jQuery文档准备功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆