jQuery多文档就绪队列顺序 [英] jQuery multiple document ready queue order

查看:114
本文介绍了jQuery多文档就绪队列顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道在jQuery中对$(function(){})的调用是按照定义的顺序执行的,但是我想知道是否可以控制队列的顺序?

I know calls to $(function(){ }) in jQuery are executed in the order that they are defined, but I'm wondering if you can control the order of the queue?

例如,是否可以在"Hello World 1"之前调用"Hello World 2":

For example, is it possible to call "Hello World 2" before "Hello World 1":

$(function(){ alert('Hello World 1') });
$(function(){ alert('Hello World 2') });

问题是,是否有可能……我已经知道这违反了最佳实践;)

The question is whether or not it's possible... I already know it goes against best practice ;)

推荐答案

这些函数已添加到私有数组readyList中,所以我认为无法对其进行操作.

Those functions are added to a private array readyList, so I'd say it isn't accessible for manipulation.

http://github.com/jquery/jquery /blob/master/src/core.js#L47

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

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