[英]will jquery triggers any event after it loaded
I want to run some code after jquery load. 我想在加载jQuery后运行一些代码。 Will jquery fires any event after it is completely loaded. 完全加载后,jquery将触发任何事件。 I don't want to wait until the document ready event. 我不想等到文档准备好事件。 There are lot of javascripts in my case and I want to do some operation after jquery loaded. 在我的情况下有很多JavaScript,我想在加载jquery之后执行一些操作。 I won't be able to keep this function right after jquery. jQuery之后,我将无法立即保留此功能。 So I want a event so that I can perform the function once jquery loaded 所以我想要一个事件,以便在加载jQuery后可以执行该功能
The reason for writing your jQuery inside document ready is to ensure that you don't get an error by trying to select a DOM element that isn't in the document yet. 准备好在文档内部编写jQuery的原因是,通过尝试选择文档中尚不存在的DOM元素来确保您不会出现错误。 So if you're event involves some DOM element not waiting for document ready could cause an error. 因此,如果您的事件涉及某些DOM元素,则不等待文档准备就绪可能会导致错误。
This would be a time where I would trigger a custom event that will run just before $(document).ready()
triggers. 在这段时间里,我将触发一个自定义事件,该事件将在$(document).ready()
触发之前运行。
So, somewhere else in your code, instead of using $(document).ready
, you would use: 因此,您可以在代码的其他位置使用$(document).ready
来代替:
$(window).bind('setup', function() {
//code here...
});
And / Or 和/或
$(window).bind('loaded', function() {
//any other code here...
});
And in your one and only ready
handler, you'd do something like this: 在您唯一的一个ready
处理程序中,您将执行以下操作:
$(document).ready(function() {
$(window).trigger('setup');
$(window).trigger('loaded'):
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.