當包含在Wordpress主題的標題中時,我會在小的背景動畫腳本中看到下面顯示的錯誤(73TypeError),這會打破腳本。我沒有看到任何錯誤,當包括非WordPress的網頁上的腳本:Wordpress中斷jQuery背景動畫腳本
下面是腳本:
$(function() {
$(".bottom").hover(function() {
$(this).animate({
backgroundPosition : '0px 35px'}
, 300); }
, function() {
$(this).animate({
backgroundPosition : '0px 0px'}
, 600); }
);
}
);
可能有人建議在是什麼原因造成這個錯誤?
感謝,
尼克
這是因爲jQuery沒有加載。閱讀這個[wp_enqueue_script](http://codex.wordpress.org/Function_Reference/wp_enqueue_script) – undefined
哦,jQuery顯示在頁面上的腳本列表中,所以我推測它已包含在內。我添加了<?php wp_enqueue_script(「jquery」); ''在wp_head();'上面''在我的子主題的header.php文件中,現在我得到錯誤'TypeError:'undefined'不是函數(評估'$')'在上述倒數第二行腳本 – Nick
單擊列表中加載的jQuery文件並檢查是否正確加載。 – undefined