我正在开发一个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