我在 CDN 的帮助下在 HTML 页面中使用 JQuery 代码,但在没有互联网连接的情况下无法测试它。我只是在开发。
如何在 Google CDN 之外的本地启用 Jquery 代码
最佳答案
下载js
文件并将其保存在本地,然后如果您的cdn
加载失败,您可以使用 native 回退到本地版本。
例如
<script src="//ajax.aspnetcdn.com/ajax/jquery/jquery-2.0.0.min.js"></script>
<script>window.jQuery || document.write('<script src="localpathhere/jquery-2.0.0.min.js">\x3C/script>')</script>
<!--The second line of code checks whether jquery has been loaded correctly else it will
write a new script where local file gets referred-->
关于javascript - JQUERY 包含方法以启用 jquery 代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34014556/