我正在開發一個WordPress網站http://fremont.alchemycs.com,我一直在遇到jQuery問題。頁面上有兩個使用jQuery的功能 - 頁面頂部的幻燈片顯示和邊欄中的手風琴菜單。出於某種原因,我無法讓他們同時工作。根據我加載jQuery的位置,我得到「不是函數」的錯誤。jQuery加載問題
這裏是我的頭,因爲它代表的時刻:
<!DOCTYPE html>
<html dir="ltr" lang="en-US">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="initial-scale=1.0, width=device-width" />
<title>Fremont, Seattle</title>
<link rel="profile" href="http://gmpg.org/xfn/11" />
<link rel="stylesheet" type="text/css" media="all" href="http://fremont.alchemycs.com/wp-content/themes/center/style.css" />
<link rel="pingback" href="http://fremont.alchemycs.com/xmlrpc.php" />
<!--
<script src="http://fremont.alchemycs.com/wp-content/themes/center/js/modernizr-1.6.min.js"></script>
-->
<link rel="alternate" type="application/rss+xml" title="Fremont, Seattle » Feed" href="http://fremont.alchemycs.com/feed/" />
<link rel="alternate" type="application/rss+xml" title="Fremont, Seattle » Comments Feed" href="http://fremont.alchemycs.com/comments/feed/" />
<link rel="alternate" type="application/rss+xml" title="Fremont, Seattle » Home Comments Feed" href="http://fremont.alchemycs.com/home/feed/" />
<link rel='stylesheet' id='ccf_custom-css' href='http://fremont.alchemycs.com/wp-content/plugins/constant-contact-form/class/ccf_custom.css?ver=3.2.1' type='text/css' media='screen' />
<link rel='stylesheet' id='contact-form-7-css' href='http://fremont.alchemycs.com/wp-content/plugins/contact-form-7/styles.css?ver=3.1' type='text/css' media='all' />
<link rel='stylesheet' id='amr-ical-events-list-css' href='http://fremont.alchemycs.com/wp-content/plugins/amr-ical-events-list/css/icallist.css?ver=1' type='text/css' media='all' />
<link rel='stylesheet' id='amr-ical-events-list_print-css' href='http://fremont.alchemycs.com/wp-content/plugins/amr-ical-events-list/css/icalprint.css?ver=1' type='text/css' media='print' />
<script type='text/javascript' src='http://fremont.alchemycs.com/wp-includes/js/l10n.js?ver=20101110'></script>
<script type='text/javascript' src='http://fremont.alchemycs.com/wp-content/plugins/constant-contact-form/class/ccf_ajax.js?ver=3.2.1'></script>
<script type='text/javascript' src='http://fremont.alchemycs.com/wp-includes/js/jquery/jquery.js?ver=1.6.1'></script>
<script type='text/javascript' src='http://fremont.alchemycs.com/wp-content/plugins/jquery-vertical-accordion-menu/js/jquery.hoverIntent.minified.js?ver=3.2.1'></script>
<script type='text/javascript' src='http://fremont.alchemycs.com/wp-content/plugins/jquery-vertical-accordion-menu/js/jquery.cookie.js?ver=3.2.1'></script>
<script type='text/javascript' src='http://fremont.alchemycs.com/wp-content/plugins/jquery-vertical-accordion-menu/js/jquery.dcjqaccordion.2.9.js?ver=3.2.1'></script>
<script type='text/javascript' src='http://fremont.alchemycs.com/wp-includes/js/comment-reply.js?ver=20090102'></script>
<link rel="EditURI" type="application/rsd+xml" title="RSD" href="http://fremont.alchemycs.com/xmlrpc.php?rsd" />
<link rel="wlwmanifest" type="application/wlwmanifest+xml" href="http://fremont.alchemycs.com/wp-includes/wlwmanifest.xml" />
<link rel='index' title='Fremont, Seattle' href='http://fremont.alchemycs.com/' />
<link rel='next' title='Calendar' href='http://fremont.alchemycs.com/events/' />
<meta name="generator" content="WordPress 3.2.1" />
<!-- All in One SEO Pack 1.6.13.8 by Michael Torbert of Semper Fi Web Designob_start_detected [-1,-1] -->
<meta name="description" content="The Center of the Universe" />
<link rel="canonical" href="http://fremont.alchemycs.com/" />
<!-- /all in one seo pack -->
<link rel="stylesheet" type="text/css" href="http://fremont.alchemycs.com/wp-content/plugins/social-media-widget/social_widget.css" />
<link rel='stylesheet' id='wop-css' href='http://fremont.alchemycs.com/wp-content/plugins/widgets-on-pages/wop.css' type='text/css' media='all' /><!-- BEGIN Hackadelic Sliding Notes 1.6.5 -->
<style type="text/css">
.concealed { display: none }
.block { display: block }
</style>
<!-- END Hackadelic Sliding Notes 1.6.5 -->
<script src="http://fremont.alchemycs.com/wp-content/themes/center/js/jquery.flexslider.js"></script>
<link rel="stylesheet" type="text/css" media="all" href="http://fremont.alchemycs.com/wp-content/themes/center/css/flexslider.css" />
<script type="text/javascript" charset="utf-8">
$(window).load(function() {
$('.flexslider').flexslider();
});
</script>
</head>
當上面是我的頭,我得到一個錯誤信息:$是不是一個函數
但是,如果我改變標題在稍後的頭文件中加載jQuery,我得到了有關手風琴菜單功能的類似錯誤。
這可能很簡單,但我很難搞清楚。
謝謝!
編輯 - 讓我強調一下,我已經試過了我在哪裏加載jQuery,即使我在頁眉的頂部這樣做,所以它是第一件事,只有一個腳本可以工作。
現在,jQuery就是它插件放在那裏的地方。但爲了試圖實現這一點,我刪除了插件的jQuery調用,並將jQuery放在標題頂部。我仍然遇到同樣的問題 - 頁面上只有一個jQuery函數可以工作。 – Gwendydd 2012-02-15 22:03:40
正如Tuncay Demirtepe所說,jQuery而不是$工作,由於某種原因,您的jQuery版本不正確,當我將http://code.jquery.com/jquery-1.6.1.min.js包含到您的頁面中時很好。你應該使用jQuery(window)....或者用正確的版本覆蓋文件。 – Qurben 2012-02-15 22:16:42
你的文件確實是按照正確的順序排列的,jQuery核心之前的文件與jQuery無關。 – Qurben 2012-02-15 22:20:23