所有, 我有下面的代碼:jQuery的DOM中沒有窗戶裝
$(document).ready(function() {
// more code using $ as alias to jQuery
alert('it works');
},'jQuery');
頁面加載時我得到以下錯誤:
Uncaught TypeError: Property '$' of object [object DOMWindow] is not a function
我已經加載之前的jQuery我試圖添加這個。
下面是這是怎麼裝的(我的代碼是custom.js):
<script type='text/javascript' src='http://localhost/oml_live_update/wp-includes/js/jquery/jquery.js?ver=1.7.1'></script>
<script type='text/javascript' src='http://localhost/oml_live_update/wp-content/themes/alyeska/framework/frontend/assets/plugins/prettyphoto/js/jquery.prettyPhoto.js?ver=3.1.3'></script>
<script type='text/javascript' src='http://localhost/oml_live_update/wp-content/themes/alyeska/framework/frontend/assets/js/superfish.js?ver=1.4.8'></script>
<script type='text/javascript' src='http://localhost/oml_live_update/wp-content/themes/alyeska/framework/frontend/assets/js/flexslider.js?ver=1.8'></script>
<script type='text/javascript' src='http://localhost/oml_live_update/wp-content/themes/alyeska/framework/frontend/assets/js/roundabout.js?ver=1.1'></script>
<script type='text/javascript' src='http://localhost/oml_live_update/wp-content/themes/alyeska/assets/js/alyeska.min.js?ver=1.0'></script>
<script type='text/javascript' src='http://localhost/oml_live_update/wp-content/themes/alyeska/assets/js/custom.js?ver=1.0'></script>
爲什麼這是行不通的任何想法?
什麼時候在代碼之前或之後加載jquery腳本? – Gabe 2012-03-14 22:55:59
你在這段代碼之前添加了jQuery文件嗎? – 2012-03-14 22:56:29
你在做錯事。可能你沒有收錄jquery文件。它正在處理[jsfiddle](http://jsfiddle.net/DD5jJ/) – Dips 2012-03-14 22:58:02