2014-05-15 124 views
0

我想加載一些jquery窗口加載但是我收到'jQuery未定義'的錯誤。jquery未定義wordpress窗口加載

這是我的jQuery。

jquery(function($) { //jQuery passed in as first param, so you can use $ inside 
jquery(window).load(function ($) { 
    $('#newsPost').masonry({ 
     columnWidth: '.col-lg-6', 
     itemSelector: '.item' 
    });  
}) 
}); 

我已經在文檔準備好的情況下正常工作,但窗口加載未定義。


下面是該最終工作版本的更新:

jQuery(function($) { 
$(window).load(function() { 
$('#newsPost').masonry({ 
    columnWidth: '.col-lg-6', 
    itemSelector: '.item' 
});  
}) 
}); 
+0

因爲當你調用這個函數時jquery還沒有準備好? – moped

回答

0

更換jqueryjQuery$

您確定您已經加載了jquery腳本文件嗎?

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script> 
+0

檢查更新後的答案......並且';'在最後第二行缺少。 – hsuk

+0

你以前的回答是對的。我已更新顯示工作版本的問題。 – probablybest

+0

更新的前一個答案。 – hsuk