我可以在页面上声明多少次jQuery的文档就绪功能? [英] How many times can I have jQuery's document ready function declared on a page?
本文介绍了我可以在页面上声明多少次jQuery的文档就绪功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
允许在页面上声明jQuery文档ready函数多少次,即:
How many times is it permitted to have the jQuery document ready function declared on a page, i.e.:
$(function () { ... });
或
$(document).ready(function () { ... });
两者之间有区别吗?
如果允许一个以上,它们会按声明顺序开火吗?
If it's permitted more than one, do they fire in order of declaration?
推荐答案
一个:两者没有区别.
报价:
All three of the following syntaxes are equivalent:
$(document).ready(handler)
$().ready(handler) (this is not recommended)
$(handler)
两个:您可以根据需要拥有任意数量的对象,它们将按照执行$()
或$(document).ready()
函数的顺序执行. (即,每个处理程序都添加到了队列中)
Two: You can have as many of them as you wish, and they will be executed in the order that the $()
or $(document).ready()
functions are executed. (i.e. each handler is added to the queue)
这篇关于我可以在页面上声明多少次jQuery的文档就绪功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文