这是我的html
<div id="projekt" style="position: relative; width: 90%;height:400px;"/>
$("#projekt").ready(function() {
.. do something with the div
});
问题是ready函数被调用了两次。可能的原因是什么?
发布于 2010-11-05 23:41:12
那是a bug which can cause this。尝试更新或绑定到文档,而不是div。
发布于 2011-12-10 19:14:31
我找到了这个问题的解决方案。
您应该使用以下代码
$(document).bind("ready", MyDocumentReadyHandler)
而不是代码
$(document).ready(...);
您可以使用此url阅读有关"ready“函数的更多信息。
发布于 2011-04-12 08:59:15
当我在.ready回调中的某个地方有一个警告(‘...’);时,我就看到过这种情况。这发生在最近的jQuery 1.5.2版本中。删除警报会使代码只运行一次。
https://stackoverflow.com/questions/4107445
复制相似问题