JQuery Document Ready - Multiple allowed? [duplicate]

大憨熊 提交于 2021-02-07 20:51:15

问题


Possible Duplicate:
jQuery - is it bad to have multiple $(document).ready(function() {});
Can you have multiple $(document).ready(function() sections?

I would like to know if it's allowed to have multiple instances of:

$(document).ready(function(){

})

on one of several pages ?


回答1:


Yes. Not a problem to do that.

Just to extend on that: http://jsfiddle.net/CBCrZ/




回答2:


not sure what you mean by on several pages. But yes you can have multiples of document.ready. They will get called in the order you add them.




回答3:


Is fine to have more than one. The call order is the same as the definition order: first-come first-served.

See also here: second $(document).ready event jQuery




回答4:


Yes. You can use it more than once. see this post

http://docs.jquery.com/Tutorials:Multiple_$(document).ready()



来源:https://stackoverflow.com/questions/8743599/jquery-document-ready-multiple-allowed

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!