我是jquery的新手,想問一個簡單的問題。我有一個jQuery文件說asdfg.js
。首先追加jquery文件(更改js文件的順序)
此文件需要jquery.js
。
在這個文件中,我正在檢查jquery.js是否已經加載。如果jquery未加載,請包含js文件。
我使用下面的代碼:
if (window.jQuery) {
alert("jQuery library is loaded!");
} else {
var elmScript = document.createElement('script');
elmScript .src = 'http://localhost/new_customer/js/jquery-1.7.2.min.js'; // change file to your jQuery library
elmScript .type = 'text/javascript';
document.getElementsByTagName('head')[0].appendChild(elmScript);
}
但這個文件加載jquery.js
後asdfg.js
文件,在其中我工作。那麼,如果我想在asdfg.js
之前加載這個jquery.js
,我該怎麼辦?
你爲什麼不只是包括jQuery的在你的HTML你'包括前asdfg.js'? – Broxzier