在$(document).ready()中包含外部jQuery文件 [英] Enclosing external jQuery file in $(document).ready()

查看:84
本文介绍了在$(document).ready()中包含外部jQuery文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有外部JavaScript文件,只包含jQuery。我应该在$ (文件).ready()中附上每个外部文件中的所有代码吗?这里的最佳做法是什么?

I have external JavaScript files that contain only jQuery. Should I enclose all of the code in each of these external files in $(document).ready()? What is the best practice here?

谢谢!

推荐答案

包括它们位于页面上方的jquery脚本,并以正常方式包含其后的每个脚本。但是在每个脚本中,将所有必要的代码放在$(document).ready()结构中。你可以多次使用它;你不仅限于一次。

Include the jquery script above them in your page, and have each of the other scripts included after it, in the normal way. But inside each of those scripts, put all the necessary code in the $(document).ready() structure. You can use it multiple times; you aren't restricted to just once.

这篇关于在$(document).ready()中包含外部jQuery文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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