我想在myjs.js文件中包含jquery.js。我为此写了下面的代码。如何将jquery.js包含在另一个js文件中?
var theNewScript=document.createElement("script");
theNewScript.type="text/javascript";
theNewScript.src="http://example.com/jquery.js";
document.getElementsByTagName("head")[0].appendChild(theNewScript);
$.get(myfile.php);
第5行显示错误'$ not defined'。我想包含jquery.js,然后在myjs.js文件中调用$ .get()函数。我怎样才能做到这一点? 请帮我
为什么你想要在页面之外使用$ .get()? – Calum 2011-04-07 08:05:50
我假设你打算说'$ .get(“myfile.php”);'而不是'$ .get(myfile.php);'。 – 2011-04-07 08:22:43
[检查jquery是否已被加载,然后加载它如果为false]可能的重复(http://stackoverflow.com/questions/1828237/check-if-jquery-has-been-loaded-then-load-it-if - 假) – 2014-06-01 08:25:33