$(document).ready(initialize)和$(document).on('ready',initialize)之间有什么区别 [英] what is the difference between $(document).ready(initialize) and $(document).on('ready',initialize)
本文介绍了$(document).ready(initialize)和$(document).on('ready',initialize)之间有什么区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有什么区别:
$(document).ready(initialize);
和
$(document).on('ready',initialize);
对我来说,他们似乎以同样的方式工作。
To me they seem to work in the same way.
推荐答案
$(document).on('ready',initialize);
如果已经是DOM,则无效文件执行时就绪。
$(document).on('ready',initialize);
will not work if the DOM is already ready when the file is executed.
$(文件).ready()
对此进行了特殊处理:它确保它总是被称为
$(document).ready()
has a special handling for this: it ensures it is always called
这篇关于$(document).ready(initialize)和$(document).on('ready',initialize)之间有什么区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文